From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15908 invoked from network); 7 Jan 2002 17:38:29 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 7 Jan 2002 17:38:29 -0000 Received: (qmail 7208 invoked by alias); 7 Jan 2002 17:38:23 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 16412 Received: (qmail 7197 invoked from network); 7 Jan 2002 17:38:22 -0000 From: "Bart Schaefer" Message-Id: <1020107173817.ZM9903@candle.brasslantern.com> Date: Mon, 7 Jan 2002 17:38:16 +0000 In-Reply-To: <3C1DE505.AFA6AB06@yahoo.co.uk> Comments: In reply to Oliver Kiddle "Re: PATCH: += parameter assignments" (Dec 17, 12:28pm) References: <000001c186f3$f4b82bd0$21c9ca95@mow.siemens.ru> <3C1DE505.AFA6AB06@yahoo.co.uk> X-Mailer: Z-Mail (5.0.0 30July97) To: Oliver Kiddle Subject: Re: PATCH: += parameter assignments Cc: zsh-workers@sunsite.dk MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Dec 17, 12:28pm, Oliver Kiddle wrote: } Subject: Re: PATCH: += parameter assignments } } Borsenkow Andrej wrote: } > } > > One possible extension beyond what ksh does would be to also add a -= } > > assignment. It could be made to prepend to string and array values } } > I would prefer += and =+ but that probably breaks ksh93 compatibility. } } This issue wouldn't be ksh93 compatibility so much as backward } compatibility with old zsh scripts or any other scripts. Sorry not to have followed up on this one sooner, but it came along as I was getting ready for winter holidays and I didn't have time. I'm not entirely happy with the addition of the a+=val syntax because it conflicts (conceptually, not mechanically) with the += operator that is already present in the math syntax. Consider that the following: integer i=4 typeset s=4 i+=5 s+=5 ((i+=5)) ((s+=5)) print $i $s yields 14 50 However, what I consider to be worse is that: s=four ((s+=5)) s+=5 print $s yields 55 Interpreting strings as integers in math context makes some sort of sense, but doing both that, and also overloading += depending on the parameter type, is going too far. I think the suggested change for -= would be even more confusing. And the following can't be anything but a bug: s=4four ((s+=5)) s+=5 print $s yeilds zsh: bad math expression: operator expected at `four' 65 (Previously s=4four ((s+=5)) print $s gave zsh: bad math expression: operator expected at `four' 4four but now it somehow reassigns s as 6.) -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net