[bitc-dev] No operator precedence [was: Syntax: procedure call.]
Jonathan S. Shapiro
shap at eros-os.org
Sun Apr 11 15:30:25 PDT 2010
So the curried thing isn't always so great. Compare:
(define (fact x:int32)
(cond ((< x 0) (- (fact (- x))))
((= x 0) 1)
(otherwise
(* x (fact (- x 1))))))
// curried:
def fact x =
if (x < 0) then - (fact (-x))
else if (x == 0) then 1
else x * fact (x - 1)
// non-curried:
def fact x =
if (x < 0) then - fact(-x)
else if (x == 0) then 1
else x * fact(x - 1)
In particular, look what happens with unary operators in the first leg
of the if/then/else. Perhaps precedence solves some of this, but to my
eyes:
- fact - x
does not parse obviously to me as a reader.
More information about the bitc-dev
mailing list