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

Re: arithmetic operator precedence



2008/6/19 Vincent Lefevre <vincent@xxxxxxxxxx>:
> On 2008-06-19 14:29:03 +0200, Richard Hartmann wrote:
>> On Thu, Jun 19, 2008 at 11:58, Peter Stephenson <pws@xxxxxxx> wrote:
>> > That seems a good idea in any case.
>>
>> Can you add that this is done to remain both backwards and shell-
>> compatible and that this is not what a 'real' language/calculator
>> will do?
>
> This isn't shell-compatible. AFAIK, only bash and ksh93 support **.
>
>> Perhaps even include a reference to the POSIX argument.
>
> There's no POSIX argument. ** is just an extension.

I've followed this discussion, and I'm left wondering only one thing.
If it's decided that $(( -1 ** 2 )) == 1, then what's the point? Why
would anyone ever write that? Why require everyone to write -(1**2) when
the expression makes no sense at all without the parentheses? Ie you would
just write 1**2 without the - at all, nobody would ever write (-1)**2.

-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author