zsh-workers
 help / color / mirror / code / Atom feed
* Treatment of illegal indices
@ 1998-02-22 15:07 Bernd Eggink
  1998-02-22 18:11 ` Bart Schaefer
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Bernd Eggink @ 1998-02-22 15:07 UTC (permalink / raw)
  To: Zsh-workers

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.
This doesn't make much sense and can cause hard-to-detect errors.
Somebody who uses an index of -4711 in a 10-element array almost
certainly doesn't want to address element 1. 

Possible improvements could be:

a) Always print an error message if an illegal index is used.
b) Do nothing if an illegal index is used on the left side of an       
assignment, return an empty value otherwise.
c) Print an error message if an illegal index is used on the left      
side of an assignment, return an empty value otherwise.

Personally, I'd prefer c). And, although I think zsh has too many
options already, an additional option which toggles between a) and c)
could be useful.

What does everybody think? I'd volunteer to make a patch if I get
positive feedback.

- Bernd

-- 
Bernd Eggink
Regionales Rechenzentrum der Universitaet Hamburg
eggink@rrz.uni-hamburg.de
http://www.rrz.uni-hamburg.de/eggink/BEggink.html


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~1998-02-25 14:25 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-02-22 15:07 Treatment of illegal indices Bernd Eggink
1998-02-22 18:11 ` Bart Schaefer
1998-02-23  9:23 ` Peter Stephenson
1998-02-23  9:25 ` Andrew Main
1998-02-23 10:22   ` Peter Stephenson
1998-02-25 12:13 ` Bernd Eggink
1998-02-25 12:33   ` Andrew Main
1998-02-25 14:02     ` Bernd Eggink
1998-02-25 14:11       ` Andrew Main

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).