[Top][All Lists]

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

How to tell a function from a string

From: John W. Eaton
Subject: How to tell a function from a string
Date: Tue, 20 Jan 1998 00:40:04 -0600

On 17-Jan-1998, Lorenzo M. Catucci <address@hidden> wrote:

| Dear readers,
|       here I am with my first question:
| In the comments after definition of newtroot, in Octave's manual, I read:
| <  Note that this is only meant to be an example of calling
| < user-supplied functions and should not be taken too seriously.  In
| < addition to using a more robust algorithm, any serious code would check
| < the number and type of all the arguments, ensure that the supplied
| < function really was a function, etc.
| Now, since I didn't find an is_function() function, I'd like to know how
| must I act to make sure what was passed as a function name is really
| registered with the parser (or can be registered) as a function.

Unfortunately, there isn't a good way to do this from Octave, though
you could probably wrap is_valid function from src/ in a
DEFUN easily enough.

| While I'm on this, how do I do the same from c++?

In 2.0.x, you can do something like this (from src/

  tree_fvc *lsode_fcn = is_valid_function (args(0), "lsode", 1);

  if (! lsode_fcn)
    error ...

In 2.1.x and later the interface will change.  You will have to use
octave_function* instead of tree_fvc*.


reply via email to

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