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

Re: array prepend



[redirected to -workers]

On Jan 13,  6:51pm, Peter Stephenson wrote:
} Subject: Re: array prepend
}
} On Sat, 12 Jan 2013 02:38:13 +0100
} Oliver Kiddle <okiddle@xxxxxxxxxxx> wrote:
} > If you dig out the mailing list discussion from when += was added
} > you'll see that the main reason there isn't a prepend is that we
} > couldn't think of suitable syntax that would be backward compatible.
} 
} I was thinking about /=.  I started looking at it once but got bored
} with all the varieties of parameter type.

Hrm, I'm not exactly excited by that choice, /= implies some sort of
division rather than union.

} > -= for example
} > isn't possible because a - character is valid in an identifier.

Thinking again, I'm not sure that's the reason.  There doesn't seem to
be any syntactic reason to exclude -= (it doesn't parse now); rather,
=+ doesn't work because a + character is valid in the parameter value,
but I think -= was rejected on the same implied-semantics grounds that
I just raised for /=.

What about a special case for empty brackets?  VAR[] is not currently
a valid identifier even though e.g. VAR[*] is.

 	VAR[]=(this is prepended)
 	VAR[]+=(this is appended)
 	VAR+=(short for 'VAR[]+=')



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