[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: thoughts on onCleanup and handle classes
From: |
John W. Eaton |
Subject: |
Re: thoughts on onCleanup and handle classes |
Date: |
Tue, 18 May 2010 11:51:56 -0400 |
On 18-May-2010, Jaroslav Hajek wrote:
| comments, suggestions? OK to push?
It would be nice to have this functionality, as I think it has already
been reported as missing a few times.
I originally objected to the idea of implementing it apart from handle
classes because I thought there would be too many differences between
a one-off C++ implementation and the way it would work if implemented
using a handle class object. But maybe that doesn't matter anyway, if
all the normal use cases are handled.
In Matlab, what happens for the following
%% argument is not a function handle
c = onCleanup (1)
clear c
With your patch, Octave complains that the argument is not a function
handle. Is Matlab that strict? If not, then is there some reason to
allow arguments other than function handles?
c = onCleanup (@() disp ('foobar'))
save foo.mat
clear all
load foo.mat
c
If the value is preserved, then what should we do? I would guess that
it is not too helpful to save and restore cleanup functions, so it
seems that it should be OK to just skip them as Octave does now with
your patch.
c = onCleanup (@() disp ('foobar'))
isa (c, 'class')
isa (c, 'handle')
Will it cause trouble if Matlab returns true for "isa (c, 'handle')"
and Octave does not? I don't see how faking this in Octave would
help, as we don't have handle classes. Note that this is separate
from the "ishandle (c)", which tests for graphics handle objects, not
handle class objects, and so "ishandle (c)" should return false in
this case.
Thanks,
jwe
Re: thoughts on onCleanup and handle classes, David Bateman, 2010/05/18