From octave-sources-request at bevo dot che dot wisc dot edu Wed Jun 6 01:43:43 2001 Subject: Re: Cell array support From: Paul Kienzle To: Jianming Cc: octave-sources , "John W. Eaton" Date: Wed, 6 Jun 2001 07:43:32 +0100 On Wed, Jun 06, 2001 at 09:31:52AM +0800, Jianming wrote: > Hi, > I hope you have seen my recent cell array patch on octave-sources. Here > are some more thoughts I have when digging through octave code, trying to > implement more cell functions. > > > IMHO, "x(idx) = []" for deletion is already pretty arbitrary (shouldn't it > > produce a dimension conflict?), so I don't put too weight on consistency. > > > > I would be happier if deletion was identified in the parser, rather > > than relying on the semantics of assignment from a particular value. > > Something like "clear x(idx)" would be even less confusing. And less > > error prone: consider "x(j) = b" where you are expecting a scalar b, > > but someone passed b as [] instead. However, interpreting assignment > > from and empty matrix as deletion of the indexed values is the defacto > > standard, at least in Matlab, RLaB, SciLab and Octave. > > The assignment to empty values causes deletion at the underlying Array and > Array2 classes. For matrix, empty values are []. For octave, empty values > are {}. That is way the deletion cellvar(idx)={}will require no addtional > work for the parser, and indeed for the intermediate classes, which is quite > convienent and clean. Hence, I would not recommand special code to perform > cellvar(idx)=[]. However, for consistency with Matlab etc, I guess we can > create a special variable called maybe DELCELL. In octave, DELCELL={}, in > Matlab etc DELCELL=[]. Hence, the users would use cellvar(idx)=DELCELL, and > porting would not be a problem. The following bit of code gives an array dimension mismatch error in matlab, so your idea won't work. y=[]; x(I) = y; Paul Kienzle pkienzle at users dot sf dot net ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------