Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: array prepend
- X-seq: zsh-workers 30967
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: array prepend
- Date: Mon, 14 Jan 2013 16:48:17 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s1024; t=1358178498; bh=+VrJZWyPM4el5MpDaEnhljiigVeOFWdoc2g55Jrvvho=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:Received:In-reply-to:From:References:To:Subject:Date:Message-ID; b=B44mY5rZyWuabacJDG2JcECuYBZg6IKg44xisCW/Zpg22G6KEotAwptM/qIQgDdSZr8OHPi9F4Y2fJyca66t4T5zb344MQC7pRFhlGN+0/NaZyMCDeelpikQbjFY2Ud6Z9FVd3uv50Qgr38UefPBqHaS5H3n3Yj+F2BuTQIXTEM=
- In-reply-to: <130113175023.ZM5855@torch.brasslantern.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <50EFB80D.30002@sergio.spb.ru> <22417.1357954693@thecus.kiddle.eu> <20130113185141.4394d532@pws-pc.ntlworld.com> <130113175023.ZM5855@torch.brasslantern.com>
Bart wrote:
> Hrm, I'm not exactly excited by that choice, /= implies some sort of
> division rather than union.
I was thinking of ^= (given the meaning of ^ in a regex) but that also
implies a mathematical operation. Also note that the current += does do
addition given integer variables much as i=foo is also sensitive to an
existing integer i variable.
> 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 /=.
You're right, with -= it looks for a matching command name. Digging back
in the mail archives it seems I've remembered the reasons wrongly.
> 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[]+=')
That seems reasonably logical. Would the following be possible to prepend
to an array element?
VAR[1][]="first"
Oliver
Messages sorted by:
Reverse Date,
Date,
Thread,
Author