[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Function handles, feval's docstring
From: |
John W. Eaton |
Subject: |
Re: Function handles, feval's docstring |
Date: |
Mon, 8 Aug 2011 12:31:51 -0400 |
On 8-Aug-2011, Ben Abbott wrote:
| On Aug 7, 2011, at 10:26 PM, Jordi Gutiérrez Hermoso wrote:
|
| > feval seems to have an outdated docstring that says Octave doesn't
| > have function pointers, probably from the days when Octave didn't have
| > function handles. Would it make sense to change this to say that feval
| > is most useful when you have function names as strings instead of
| > handles?
| >
| > Furthermore, is there a function like "isfunction" or something to
| > test if a variable is a function handle? If not, can I make one? What
| > should it be called?
| >
| > Thanks,
| > - Jordi G. H.
|
|
| A simple implementation would be ...
|
| isfunction = @(h) strcmp (class (h), 'function_handle')
How about
isa (h, "function_handle")
? I think we should just recommend using isa for cases where checking
exact object classes is needed instead of adding many more is*
functions. Why should we add one for function handles if we don't
also add them for all other types that currently don't have them
(isintN, isuintN, isdouble).
jwe