Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: arithmetic operator precedence



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