[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Function handles for nonexisting functions
From: |
John W. Eaton |
Subject: |
Re: Function handles for nonexisting functions |
Date: |
Wed, 22 Apr 2009 20:50:52 -0400 |
On 22-Apr-2009, Judd Storrs wrote:
| On Mon, May 5, 2008 at 5:50 PM, Moritz Borgmann <address@hidden> wrote:
|
| > Is this common? Are there other (reasonable) cases where it makes
| >> sense to create a handle to a function that is not visible, but will
| >> become visible later?
| >>
| >
| > I can't imagine any.
| >
|
| For what it's worth,
|
| It may be nice if octave didn't halt until it tried to actually evaluate an
| invalid handle. I'm not saying it should try and repair handles but it could
| keep invalid handles around as invalid.
|
| For example, the SPM/niftilib Matlab code appears to use bogus handles as a
| way of marking un-implemented features. They use "@crash" entries to mark
| some corner cases in a dispatch table. This is easy to work around by
| creating a crash function that crashes ;), but I don't know how common this
| sort of thinking is.
|
| In this case they used "@crash" but a matlab coder could concievably get
| really fancy and name the undefined functions such that the error hints at
| which specific feature wasn't implemented.
Will you please try the following with Matlab and tell me what
happens?
Create directories d1 and d2. Put the following fucntion in
d1/crash.m:
function crash ()
'd1/crash'
and put the following function in d2/crash.m:
function crash ()
'd2/crash'
Now start Matlab in the directory that contains d1 and d2, and run the
following commands:
fh = @crash
fh ()
cd d1
fh ()
cd ../d2
fh ()
clear all
fh = @crash ()
cd ..
fh ()
cd d1
fh ()
Now, while Matlab is still running, change the definition of
d2/crash.m to be
function crash ()
'foo'
and then continue your Matlab session with the following commands:
fh ()
cd ..
fh ()
cd d2
fh ()
clear all
addpath (pwd)
cd ..
fh = @crash
fh ()
Now, while Matlab is still running, change the definition of
d2/crash.m to be
function crash ()
'bar'
and then continue your Matlab session with the following commands:
fh ()
cd d1
fh ()
cd ../d2
fh ()
jwe
- Re: Function handles for nonexisting functions, Judd Storrs, 2009/04/22
- Re: Function handles for nonexisting functions,
John W. Eaton <=
- Re: Function handles for nonexisting functions, Judd Storrs, 2009/04/22
- Re: Function handles for nonexisting functions, Judd Storrs, 2009/04/22
- Fwd: Function handles for nonexisting functions, Judd Storrs, 2009/04/22
- Message not available
- Message not available
- Re: Function handles for nonexisting functions, Judd Storrs, 2009/04/22
- Re: Function handles for nonexisting functions, John W. Eaton, 2009/04/23
- Re: Function handles for nonexisting functions, Judd Storrs, 2009/04/23