From: "Bart Schaefer" <schaefer@brasslantern.com>
To: Oliver Kiddle <okiddle@yahoo.co.uk>
Cc: zsh-workers@sunsite.dk
Subject: Re: PATCH: += parameter assignments
Date: Mon, 7 Jan 2002 17:38:16 +0000 [thread overview]
Message-ID: <1020107173817.ZM9903@candle.brasslantern.com> (raw)
In-Reply-To: <3C1DE505.AFA6AB06@yahoo.co.uk>
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
next prev parent reply other threads:[~2002-01-07 17:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-12-17 12:02 Oliver Kiddle
2001-12-17 12:11 ` Borsenkow Andrej
2001-12-17 12:28 ` Peter Stephenson
2001-12-17 12:28 ` Oliver Kiddle
2002-01-07 17:38 ` Bart Schaefer [this message]
2002-01-14 12:45 Oliver Kiddle
2002-01-14 13:04 ` Peter Stephenson
2002-01-14 18:47 ` Bart Schaefer
2002-01-15 16:16 ` Oliver Kiddle
2002-01-15 17:54 ` Bart Schaefer
2002-01-16 14:43 ` Oliver Kiddle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1020107173817.ZM9903@candle.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=okiddle@yahoo.co.uk \
--cc=zsh-workers@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).