On Tuesday, March 29, 2011 12:24:24 you wrote: > cc: [email protected] > Subject: Re: Re: [ast-developers] ksh: problem with arrays > -------- > > > > > > > This bug was already reported and is fixed for the first bug fix release > > > of > > > ksh93u which will be distributed this quarter. > > > > > > The problem is that the declaration > > > > > > typeset xx[7]; > > > > > > is incorrectly treating xx as a fixed size array of size 7 and currently > > > fixed sized arrays only for for fixed sized objects. The declaration for > > > fixed size arrays should be > > > typeset -a xx[7]; > > > and the declaration > > > typeset xx[7]; > > > is not even necessary, but should not have been treated as a fixed array. > > > > I'll have to answer some questions, so I'd like to confirm a few things. > > > > 1) It is expected that typeset xx[7]; creates array with one empty element > > [7] s > > o > > ${#xx[@]} is really expected to be 1 despite all other shells I've tested > > don't > > create that > > element, so they report zero. Old ksh reported 0 too, this changed between > > 2008-10-01 and 2008-10-10, but I did not find anything about this in > > RELEASE fil > > e. > > This was original complain I've got so I'd like to be sure this is expected > > befo > > re I tell > > it to our users :) > > No, this was caused by the fixed array bug. > typeset xx[7] > just creates an indexed array with at least 7 elements and none are set > ${#xx[@]} should be 0. This is a bug and will be fixed.
ok, I'll forward this info, thanks > > 2) I was looking for fixed arrays at ksh man page (just searched for > > 'fixed' key > > word), > > but did not find anything. So I've looked at RELEASE file and I've found > > fixed a > > rrays > > mentioned only once (10-09-28): > > > > > ... It allows fixed sized indexed arrays be to defined > > > using "typeset array[dim1][dim2]...[dimn]". ... > > > > so should it be typeset -a xx[7] or typeset xx[7] ? > > The purpose of fixed arrays was to provide a faster and more memory > efficient array mechanism for applications that did not require > the generality of the current array mechanism which allowed each > element to be different. > > Fixed arrays were added as a compile option which is on by default but > not document in the man page. The reason is that it is not complete. It > only works for fixed size objects like integer, float, and typeset -LRZ. > It might be completed in ksh93u. The declaration will be > typeset -a array[dim1][dim2]...[dimn] > For variable objects, there is a debate as to whether unspecifed objects > will be initialized or not. For example, will > typeset -a xx[7] > have xx[i] unset or the empty string. Similarly for arrays of types, > will unset elements of type Foo_t be equivalent to Foo_t xx[i] or will > they be unset? I would interested in your opinions. Yes, that's quite interesting question. I'd propably preffer empty string over unset, but I don't have use case for this, so it's better to ask someone who already see how is he going to use it. Btw, probably caused by some bits missing and probably you know about it already, but ksh -c 'typeset -T mytype=( .hello=world ); mytype -a foo[5]' is causing sigsegv. Michal _______________________________________________ ast-developers mailing list [email protected] https://mailman.research.att.com/mailman/listinfo/ast-developers
