octave-maintainers
[Top][All Lists]
Advanced

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

fix null assignment: the (hopefully) final answer


From: Jaroslav Hajek
Subject: fix null assignment: the (hopefully) final answer
Date: Thu, 25 Sep 2008 16:16:00 +0200

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


reply via email to

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