Zsh Mailing List Archive
Messages sorted by:
Re: arithmetic operator precedence
- X-seq: zsh-workers 25180
- From: Vincent Lefevre <vincent@xxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxxxxx>
- Subject: Re: arithmetic operator precedence
- Date: Tue, 17 Jun 2008 13:19:34 +0200
- Cc: Richard Hartmann <richih.mailinglist@xxxxxxxxx>, Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- In-reply-to: <20080617094509.GC5016@xxxxxxxxxxxxxxx>
- Mail-followup-to: Zsh hackers list <zsh-workers@xxxxxxxxxx>, Richard Hartmann <richih.mailinglist@xxxxxxxxx>, Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- 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>
On 2008-06-17 10:45:09 +0100, Stephane Chazelas wrote:
> But ** is not ^, it's a binary operator whose shape reminds that
> of multiply, like a multiply++.
So, why is ** right-associative while * is left-associative?
> And even then, POSIX's ^ in bc is handled as -3^2 = 9.
But note that bc is the only calculator with such an unfortunate
choice. And I doubt that bc has been designed by end users. Also,
perhaps those who wrote bc in the first place didn't think about
this problem and just wanted to privilege the precedence of
unary operators as it is often the case.
> It could be a good idea to ask ksh, POSIX/bc and perl authors for
> the rationale behind their choices.
I think that Perl authors would say something like conventional math
writing (that's what some of authors of calculators say and what users
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: