[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Testing for function handles
From: |
Juan Pablo Carbajal |
Subject: |
Re: Testing for function handles |
Date: |
Wed, 9 Nov 2011 09:54:35 +0100 |
On Wed, Nov 9, 2011 at 9:51 AM, Juan Pablo Carbajal <address@hidden> wrote:
> On Wed, Nov 9, 2011 at 9:18 AM, Dr. Alexander Klein
> <address@hidden> wrote:
>> Good morning,
>>
>> is there any preferred way to check whether a given parameter or variable
>> contains a function handle?
>>
>> I find myself strcmp'ing the result of typeinfo quite often, but this is
>> really clumsy. Then again, ishandle only checks for graphics handles ...
>>
>> Best regards,
>>
>> Alex
>>
>> --
>> Dr. Alexander Klein, Diplom-Mathematiker
>>
>> Physiologisches Institut | TransMIT Zentrum
>> Raum 543 | für Numerische Methoden
>> Aulweg 129 | Heinrich-Buff-Ring 44
>> 35392 Giessen | 35392 Giessen
>>
>>
>
> Running
> grep -i -r --exclude-dir=".hg" --include="*.cc" function_handle .
>
> in the root of octave repository you will see that octave_values
> already have a field is_function_handle that can be used to check if
> they are function handles at C++ level.
> Would be a matter of creating a DEFUN to return the value of that
> field to get the functionality at interpreter level (I just can't find
> that implemented, my apologies if it is) as is done, for example, in
> src/strfns.cc line 297
>
> You can use
> !isnumeric(f) && (check that is not any non-numeric classes)
>
> but is much slower than strcmp(typeinfo(f),"function_handle") or
> strcmp(class(f),"function_handle")
>
> my two cents.
>
>
> --
> M. Sc. Juan Pablo Carbajal
> -----
> PhD Student
> University of Zürich
> http://ailab.ifi.uzh.ch/carbajal/
>
I forgot to say that if you are not implementing that (and provided it
is not implemented already), it would be good to add a feature request
ticket at https://savannah.gnu.org/bugs/?group=octave (you can copy
some of these e-mail is in the request). If I ever become dev I will
implement it.
--
M. Sc. Juan Pablo Carbajal
-----
PhD Student
University of Zürich
http://ailab.ifi.uzh.ch/carbajal/
- Testing for function handles, Dr. Alexander Klein, 2011/11/09
- Re: Testing for function handles, Juan Pablo Carbajal, 2011/11/09
- Re: Testing for function handles,
Juan Pablo Carbajal <=
- Re: Testing for function handles, Richard, 2011/11/09
- Re: Testing for function handles, Juan Pablo Carbajal, 2011/11/09
- Re: Testing for function handles, Richard, 2011/11/09
- Re: Testing for function handles, Richard Crozier, 2011/11/09
- Re: Testing for function handles, John W. Eaton, 2011/11/09
- Re: Testing for function handles, Juan Pablo Carbajal, 2011/11/09
- Re: Testing for function handles, John W. Eaton, 2011/11/09
- Re: Testing for function handles, Juan Pablo Carbajal, 2011/11/09
- Re: Testing for function handles, Dr. Alexander Klein, 2011/11/10
- Re: Testing for function handles, Dr. Alexander Klein, 2011/11/09