Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: arithmetic operator precedence
- X-seq: zsh-workers 25151
- From: Stephane Chazelas <Stephane_Chazelas@xxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: arithmetic operator precedence
- Date: Thu, 12 Jun 2008 16:01:26 +0100
- Cc: Zsh hackers list <zsh-workers@xxxxxxxxxx>
- In-reply-to: <080612074751.ZM8185@xxxxxxxxxxxxxxxxxxxxxx>
- Mail-followup-to: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20080612095723.GF5113@xxxxxxxxxxxxxxx> <20080612144024.542b53ad@news01> <080612074751.ZM8185@xxxxxxxxxxxxxxxxxxxxxx>
On Thu, Jun 12, 2008 at 07:47:51AM -0700, Bart Schaefer wrote:
> On Jun 12, 2:40pm, Peter Stephenson wrote:
> } Subject: Re: arithmetic operator precedence
> }
> } On Thu, 12 Jun 2008 10:57:23 +0100
> } Stephane Chazelas <Stephane_Chazelas@xxxxxxxx> wrote:
> } > "==" is meant to have precedence over &, so the above should
> } > give 1 as in C I think. All other shells do.
> }
> } This is a fairly icky incompatibility
>
> What I'm struggling (although not very hard) to remember is why Paul
> would have chosen a non-standard precedence in the first place.
I find the zsh precedence more intuitive but that's not of much
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.
Actually, I reported that bug because I wanted to double check
what the C precedence was for & vs ==. I thought that was one of
those unintuitive cases where "==" had precedence, but in doubt,
I checked with zsh's $((...)) that told me I was wrong.
Fortunately, I did reread the C precedence chart and tried with
another shell, otherwise I'd have been fooled by zsh...
But I now know that zsh's precedence is not the same as
elsewhere so I hopefully won't be fooled again.
--
Stéphane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author