help-octave
[Top][All Lists]
Advanced

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

Re: How to tell a function from a string


From: John W. Eaton
Subject: Re: How to tell a function from a string
Date: Tue, 20 Jan 1998 12:06:57 -0600

On 20-Jan-1998, Jim Van Zandt <address@hidden> wrote:

| On 17-Jan-1998, Lorenzo M. Catucci <address@hidden> wrote:
| 
| I also thought the documentation could have been more helpful.
| Eventually I found this:
| 
|  - Built-in Function:  exist (NAME)
|      Return 1 if the name exists as a variable, 2 if the name (after
|      appending `.m') is a function file in the path, 3 if the name is a
|      `.oct' file in the path, or 5 if the name is a built-in function.
|      Otherwise, return 0.
| 
| and decided that "exist(NAME) > 1" was a reasonable test.  (Can it
| ever return 4?)

No, Octave's exist function doesn't currently return 4, but I'm not
sure what Matlab uses that return code for, so if you want to write
portable code, you might want to check that first.

| I'm now surprised to read JWE's reply:
| 
| > Unfortunately, there isn't a good way to do this from Octave, though
| > you could probably wrap is_valid function from src/variables.cc in a
| > DEFUN easily enough.
| 
| What's wrong with the above test?

Uh, I just completely forgot about it.

| Also, please add a discussion to the above passage in the manual.
| Maybe something like this:
|    
|       if (exist(fname)<2)
|       error("newtroot: expecting function argument");
|       endif
|       ...
|       ensure that the supplied function really was a function, etc.   
|       The test in the example is helpful, but fails if...

Done, thanks.

| ...or explain why this test is hopeless, or whatever.

No, I think it is my memory that is hopeless...

Thanks,

jwe



reply via email to

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