Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: arithmetic operator precedence
- X-seq: zsh-workers 25158
- From: Vincent Lefevre <vincent@xxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxxxxx>
- Subject: Re: arithmetic operator precedence
- Date: Mon, 16 Jun 2008 10:17:16 +0200
- Cc: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- In-reply-to: <20080612150126.GH5113@xxxxxxxxxxxxxxx>
- Mail-followup-to: Zsh hackers list <zsh-workers@xxxxxxxxxx>, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20080612095723.GF5113@xxxxxxxxxxxxxxx> <20080612144024.542b53ad@news01> <080612074751.ZM8185@xxxxxxxxxxxxxxxxxxxxxx> <20080612150126.GH5113@xxxxxxxxxxxxxxx>
On 2008-06-12 16:01:26 +0100, Stephane Chazelas wrote:
> I find the zsh precedence more intuitive but that's not of much
ditto
> help given that I get to use those binary operators mostly only
> in C/perl, so I have to know the C precedence anyway.
>
> And having zsh behaving differently doesn't help at all.
I agree. POSIX even requires C-like behavior:
http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_04
2.6.4 Arithmetic Expansion
Arithmetic expansion provides a mechanism for evaluating an
arithmetic expression and substituting its value. The format for
arithmetic expansion shall be as follows:
$((expression))
The expression shall be treated as if it were in double-quotes,
except that a double-quote inside the expression is not treated
specially. The shell shall expand all tokens in the expression for
parameter expansion, command substitution, and quote removal.
Next, the shell shall treat this as an arithmetic expression and
substitute the value of the expression. The arithmetic expression
shall be processed according to the rules given in Arithmetic
^^^^^^^^^^
Precision and Operations , with the following exceptions:
^^^^^^^^^^^^^^^^^^^^^^^^
(the exceptions are not about precedence), where the link to
Arithmetic Precision and Operations is:
http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap01.html#tag_01_07_02_01
which corresponds to the ISO C operators.
--
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