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

Re: arithmetic operator precedence



At 0:46 PM +0100 08.6.17, Peter Stephenson wrote:
>As it looks like "some sort of"
>compatibility might as well be with other shells (so the option could
>really be called "SH_PRECEDENCES", although it's perhaps less obvious that
>means "something approximating to the precedences you probably expect if
>you are a regular programmer") this doesn't give us room for manoeuvre
>without yet another option.

-3**2 = 9 is quite counter-intuitive and "mathematically wrong",
but If the aim of the new option C_PRECECNECES (of SH_PRECEDENCES) is to
maximize the compatibility with other shells (not with perl etc.),
then I think we are forced to stick to -3**2 = 9.

Even if yet another new option is introduced which changes -3**2 to -9,
a user whould not notice it unless (s)he reads the long zsh man page
carefully.

I think it would be sufficient to add to the man page something like
"-3**2 gives 9, not -9, in zsh and many other shells.
Be sure to use parentheses -(3**2) if you want -9."

Of course I have no objection to adding yet another option.



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