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

Re: [PATCH] (?) typeset array[position=index]=value

On Sat, Jun 5, 2021 at 4:06 AM Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> On 6/5/21, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> >
> > foo=( [a]=() )
> remove foo[a]

That doesn't make sense.  foo=( [a]=z ) replaces the entire hash table
with a single element.
  foo=( [a]=() [b]=z )
would just be a very verbose way of saying foo=( b z ) ??

> > foo[a]=( z )
> set foo[a] to z
> > foo[a]=( x y )
> error

How is that any more consistent than what we have now?

> > etc.
> there probably aren't more cases

foo[(R)*a*]=( ... )

If we can assign one element to foo[a] with parens, why can't we
assign a list of elements?

> Since we've established that both unset and assignment to an element
> behaves in no way the same already for regular arrays and associative
> arrays, is there any reason to not make assignment to associative
> array slices (with the empty slice) just remove the element? The
> parsing already works and it wouldn't break any existing cases.

We can continue to have that discussion, but IMO that's orthogonal to
whether subscripts are parsed correctly by unset.

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