Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: arithmetic operator precedence
- X-seq: zsh-workers 25181
- From: Vincent Lefevre <vincent@xxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxxxxx>
- Subject: Re: arithmetic operator precedence
- Date: Tue, 17 Jun 2008 13:28:15 +0200
- In-reply-to: <20080617114340.398c731f@news01>
- Mail-followup-to: Zsh hackers list <zsh-workers@xxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20080612095723.GF5113@xxxxxxxxxxxxxxx> <20080616080726.GP10734@xxxxxxxxxxxxxxxxxxx> <20080616144211.276fb0e3@pws-pc> <2d460de70806170219k12ff4cadn441b52c48bf8076f@xxxxxxxxxxxxxx> <20080617094509.GC5016@xxxxxxxxxxxxxxx> <2d460de70806170324o5a44609x9383cc2445d67dd6@xxxxxxxxxxxxxx> <20080617103829.GD5016@xxxxxxxxxxxxxxx> <20080617114340.398c731f@news01>
On 2008-06-17 11:43:40 +0100, Peter Stephenson wrote:
> On Tue, 17 Jun 2008 11:38:29 +0100
> Stephane Chazelas <Stephane_Chazelas@xxxxxxxx> wrote:
> > Anyway, I was just curious about Peter's statement. I'm most
> > probably not as versed in maths as he is, so was curious about
> > the rationale behind his statement about -3**2 = 9 not being
> > mathematically correct.
>
> That was Vincent. I'm inclined to leave the shell the way it is since
> there seems to be no widespread agreement on having C_PRECEDENCES (which
> probably few people will set explicitly) different from other shells (for
> which it will automatically be used in the appropriate emulation).
Well, the C language doesn't have a power operator (there's a power
function, with prefix notation, so no precedence problem with it).
Concerning the precedence of & and |, I'd say that zsh should do what
POSIX requires in sh emulation mode.
Also, when people don't agree about the precedence of operators, a
solution could be to require parentheses (but I don't know if this
is easy to implement such rules). At least ambiguity is avoided.
--
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author