Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Treatment of illegal indices



Bernd Eggink wrote:
> The way zsh treats illegal array indices is pretty ugly. It simply
> replaces indices which are 0 (with KSH_ARRAYS unset) or < -length by 1.
>
> Possible improvements could be:
> 
> c) Print an error message if an illegal index is used on the left      
> side of an assignment, return an empty value otherwise.

I think this is better; it's fairly standard for interpreted languages.
The `feature' that 0 is treated as 1 has been around for a long time,
but since KSH_ARRAYS it's probably time it went.  You are supposed to
be able to extend arrays by assignment, remember:  some time ago there
was an argument about whether

23456789=''

using up a lot of memory was a bug, and it was decided it wasn't.

-- 
Peter Stephenson <pws@xxxxxx>       Tel: +39 50 911239
WWW:  http://www.ifh.de/~pws/
Gruppo Teorico, Dipartimento di Fisica
Piazza Torricelli 2, 56100 Pisa, Italy



Messages sorted by: Reverse Date, Date, Thread, Author