Function handles for nonexisting functions
Moritz Borgmann
octave at moriborg.de
Mon May 5 16:50:28 CDT 2008
>Is this really necessary? I guess one case that could come up would
>be
>
> fh = @some_function;
> addpath ("/dir/where/some_function/lives");
> fh ();
this is indeed a sick test case, which would actually work in the other brand.
>Is this common? Are there other (reasonable) cases where it makes
>sense to create a handle to a function that is not visible, but will
>become visible later?
I can't imagine any.
>How did this situation come up in the code you
>have?
I have the situation where I'm creating function handles that I can't
know a-priori if they exist. In Matlab, str2func() always succeeds
and I can check using functions(...) if it's valid; in Octave, I have
to wrap stuff in a try...catch for the case that the function didn't
exist.
I have no particular preference myself - I think either solution is
fine. Just wanted to know what others think. If there's no other
arguments for the Matlab solution, I'd tend to leave things as they
are, simply to avoid the effort of changing (and possibly breaking)
stuff.
-M
More information about the Octave-maintainers
mailing list