[Nickle] sort of a bug

Bart Massey nickle@nickle.org
Fri, 14 Feb 2003 16:42:38 -0800


This is a bug, darnit :-).

First, Nickle evaluates from left to right: you've gone to a
lot of trouble to make this happen.  Why should operator
order be any different?  (BTW, is right-to-left
associativity a part of the C standard, or just standard in
implementations?  I need to purchase or steal a copy of the
C90 spec someday...)

Second, s far as making the precedence of making postfix !
different precedence from prefix !, it should just require a
%prec declaration, no?

But this precedence change doesn't really fix the problem:
in Nickle ~x++ will still be handled the same way as in C,
which is arguably a bug because darnit, it should be
left-to-right.  Perhaps the right answer is to make ++ and
-- have higher precedence than other unary operators in
Nickle.  The current equal precedence is arguably a defect
in C, since the implicit parens will either continue to do
the same thing or detect a conceptual bug.

	Bart

In message <E18jm2n-0001Hc-00@localhost> you wrote:
> 
> Around 19 o'clock on Feb 14, "Ireland Peddlar" wrote:
> 
> > Factorial is binding tighter than the preinrement operator.
> > ++x! is parsed as ++(x!) and dies.
> 
> Hmm.  C has a single level of precedence for unary operators and groups 
> them from right to left.  You'll get the same error from the C compiler 
> with:
> 
> 	int foo (int x) { return --x++; }
> 
> Because of the right to left binding, any postfix unary operators with the 
> are effectively given higher precedence than prefix unary operators with 
> the same specified precedence.
> 
> There's a problem here though; the grammar does operator precedence based
> on the operator tokens in the input stream.  So, I can't change the 
> precedence of the factorial operator without also changing the precedence 
> of the boolean negation opertor as they share the same token.
> 
> I think that means we're stuck with this precedence inversion; I don't 
> want to gratuitously differ from C in such a subtle way.
> 
> -keith
> 
> 
> 
> _______________________________________________
> Nickle mailing list
> Nickle@nickle.org
> http://nickle.org/mailman/listinfo/nickle