[Top][All Lists]

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

isa (x, "inline function") DOES NOT WORK

From: Rik
Subject: isa (x, "inline function") DOES NOT WORK
Date: Wed, 15 Aug 2018 15:05:24 -0700

I happened to stumble upon some bad code in core Octave today.

sparse/spfun.m:38:  if (isa (f, "function_handle") || isa (f, "inline

The problem is that isa compares the CLASS of the object to the string
provided.  Inline functions are octave_value objects which share the class
"function_handle" so it is incorrect to use isa() to test for an inline. 
Instead, one needs to use typeinfo which does produce a different result.
As an example,

plot/draw/fplot.m:92:  if (strcmp (typeinfo (fn), "inline function"))

This has got to be exceedingly rare--I know most people aren't using inline
functions anymore--but I still thought I would remark on it in case it
appears in any Octave Forge packages.

I'm in the midst of replacing the isa (f, "function_handle") usage with
just is_function_handle (f) which is clearer and faster.  This is also
something that could be done in the Octave Forge packages.


reply via email to

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