[Top][All Lists]

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

Re: namespace support?

From: Jaroslav Hajek
Subject: Re: namespace support?
Date: Sun, 7 Feb 2010 06:13:17 +0100

On Sun, Feb 7, 2010 at 1:45 AM, Leo Singer <address@hidden> wrote:
> One could almost write an M-file function called "import" to implement
> this in Octave without modifying the interpreter.
> It might work by creating function handles to functions that are not
> on the path.  However, attempting to invoke a function handle that
> points to an M-file that is no longer on the path results in the
> following error message:
> error: invalid function handle
> Matlab does support function handles to functions that are no longer
> on the path.  How hard would it be to implement this in Octave?
> Leo Singer

No, this is not true in the development version:

lt-octave:1> a = @somefunc
a =


lt-octave:2> a()
lt-octave:3> cd ..
lt-octave:4> a()

But I think that "import" will be very easy once the support for the
package lookup will be done. My idea is that calling just the name
"package_name" will return a special "package" object, much like class
constructors do, that can be further indexed to get functions or
classes (because Octave allows this and always did).

This will even enable us to do

local_name = package_name;
local_name.package_func ()

The problem seems to be with function handles.
In any case, I won't work on it prior to 3.4.0 release, and I'm not
even sure it is a good idea given that I have no access to a Matlab
copy having this feature. So maybe someone else will have to do it.

RNDr. Jaroslav Hajek, PhD
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic

reply via email to

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