octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Function handles for nonexisting functions


From: John W. Eaton
Subject: Function handles for nonexisting functions
Date: Mon, 05 May 2008 03:30:41 -0400

On  4-May-2008, Moritz Borgmann wrote:

| In Matlab, I can create function handles to nonexisting functions 
| using str2func or the @ operator. Only when I try to call the 
| function, an error like the following occurs:
| 
| ??? Undefined function or method 'blabla' for input arguments of type 
'double'.
| 
| In Octave, it seems that existance of the function is checked already 
| upon creation of the function handle.

Up until now, I think there was no other way to do it because the
function lookup needs to be performed in the scope where the handle is
created.  With the changes I made over the last few days to support
dbup and dbdown, I think it should now be possible to simply store the
name of the function and the scope+context information and defer the
lookup.  Then when the handle is needed, the scope+context can be
reset and the lookup can be performed.

Is this really necessary?  I guess one case that could come up would
be

  fh = @some_function;
  addpath ("/dir/where/some_function/lives");
  fh ();

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?  How did this situation come up in the code you
have?  Or were you just testing to see what would happen?

jwe



reply via email to

[Prev in Thread] Current Thread [Next in Thread]