[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Function handles, feval's docstring
From: |
Ben Abbott |
Subject: |
Re: Function handles, feval's docstring |
Date: |
Mon, 08 Aug 2011 07:15:24 -0400 |
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')
There's something very GNU about that ;-)
>> isfunction (isfunction)
ans = 1
Regarding the name of the function, most of the other "is" functions use the
corresponding class names. So I think the appropriate options are "isfunction"
or "isfunction_handle"
Ben