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

Re: arithmetic operator precedence



On Mon, Jun 16, 2008 at 15:42, Peter Stephenson
<p.w.stephenson@xxxxxxxxxxxx> wrote:


> That's an interesting point for C_PRECEDENCES since I was trying to get
> it behave as much as possible like Perl.  What does anyone else think?

Being unsure myself, I did some somewhat extensive research. The only
mathematically correct way of doing this is

  -3**2   = -9
  (-3)**2 =  9

On the other hand, compability with the other shells is A Good Thing,
especially as this is the kind of syntax change that can break a script
in a very, very evil and hard-to-debug way.


Still, all things considered, I would say the only possible way to go is to
use the mathematically correct syntax. Both options are bad, in a way,
but this is the better one.


Richard



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