octave-maintainers
[Top][All Lists]
Advanced

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

Re: fix null assignment: the (hopefully) final answer


From: John W. Eaton
Subject: Re: fix null assignment: the (hopefully) final answer
Date: Fri, 26 Sep 2008 11:55:03 -0400

On 26-Sep-2008, Jaroslav Hajek wrote:

| On Thu, Sep 25, 2008 at 4:16 PM, Jaroslav Hajek <address@hidden> wrote:
| > hello,
| >
| > please consider the changeset at
| > http://artax.karlin.mff.cuni.cz/~hajej2am/ulozna/null-assign2.diff
| > (not attached due to size).
| >
| > This seems a much better attempt at making the null assignments
| > smarter and Matlab compatible. The main advantage over the previous
| > attempts is that null assignments are completely resolved within
| > liboctinterp.
| > Three special octave_value classes are introduced: null matrix, null
| > string and null single quoted string (initially, I tried to use just
| > one but it seemed clumsy). These are normally registered via octave's
| > type info system and appropriate conversion and assignment handlers
| > are installed as necessary. If these special values are stored to
| > variable or cell or struct element, they lose their speciality. This
| > is to prevent things like
| >
| > b = []; a(1:2) = b
| >
| > from deleting elements.
| >
| > The special values *are* allowed to be passed as function arguments,
| > contrary to what Matlab allows. This is a serious bug in Matlab that
| > prevents elements of user-defined array classes from being deleted
| > using the `= []' syntax in the same way as for built-in arrays (i.e.
| > you either check for isempty and delete always, even for a computed
| > empty matrix, or never).  A new built-in function `isnull' is provided
| > to check whether an expression is a null value, to be used in more
| > complicated cases.
| >
| > The null values are not, however, allowed to be returned from functions.
| >
| > cheers
| >
| > --
| > RNDr. Jaroslav Hajek
| > computing expert
| > Aeronautical Research and Test Institute (VZLU)
| > Prague, Czech Republic
| > url: www.highegg.matfyz.cz
| >
| 
| The Changeset is updated for better Matlab compatibility. The Matlab
| rules seem rather ad hoc, but it appears that the present state gets
| quite close apart from the strange corner cases.
| For instance, a(3:2,3:2) = [] work in Matlab, while a(3:2,3:2,3:2) doesn't, 
but
| a(3:2,[],3:2) = [] does. I think that simply ignoring all null
| assignments with zero-length index vectors is a reasonable
| approximation.

That seems reasonable.

Thanks for doing this.  I think this is a much better solution that I
was working on.

I've checked in the changes in my archive.

jwe


reply via email to

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