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

Re: PATCH: array slice



On Jun 27,  8:42pm, Peter Stephenson wrote:
} Subject: Re: PATCH: array slice
}
} On Fri, 26 Jun 2015 16:07:45 -0700
} Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
} > 
} > torch% typeset y[2,4]=(x)
} > typeset: y[2,4]: can't create local array elements
} 
} It would take more work to fix this so it does something sensible if the
} variable would be local --- we get into a mess later, which is what I
} think the error is for.  I don't quite understand why but I've
} lost interest / the will to live; there are too many combinations.

The short rationale is that "local y[1]" APPEARS TO BE attempting to
make the single element ${y[1]} local without making the rest of the
array local.  You can't do that in any case; the entire array has to
be local for any of it to be.

The same goes for assoc arrays.  Contrast this with perl where the
real "local" confusion may come from:

% perl -le '@y=(1..4); do { local $y[2]='c'; map { print } @y }'
1
2
c
4


Administrivia:  Peter's message arrived in my inbox with

To: "Zsh Hackers' List" <zsh-workers@xxxxxxxxxxxxxxxxxxxxxxxxxxx>

My email is received at gmail, so this likely happened somewhere upstream,
possibly at the list exploder itself.  Weird.  It looks correct in the
list archives.



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