It might be easier to explain, but it also makes the code look ugly. Consider the expressions:
a := b + c*d
if e > f-g then ...
Here the * and - are more tighly bound than the + or >, and I'm using the whitespace to make that obvious.It might be easier to explain, but it also makes the code look ugly. Consider the expressions:
a := b + c*d
if e > f-g then ...
Here the * and - are more tighly bound than the + or >, and I'm using the whitespace to make that obvious. a := b+c * d
you aren't going to get an error. You're just going to get awfully surprising behavior, because you may think you were expressing one precedence with the spaces but the language has its own mind and doesn't care.In contrast, Pyret doesn't bind anything more tightly than anything else. You parenthesize to make your intent clear.
If your expression gets too large, you should consider breaking it down with names for the intermediates. That will improve its readability by others anyway.
But this is a bad argument, as it could apply to any language feature. E.g. I could write a program:
def add(a, b):
return a - b
Here I've called it "add" but it does subtraction. By your argument, we should ban functions having meaningful names, as people could use a misleading one.> Pyret doesn't bind anything more tightly than anything else
So all dyadic operators have the same precedence, like in Smalltalk? How horrible.
> You parenthesize to make your intent clear.
More likely I write my code in something other than Pyret, to make my intent clear.
Then allow everyone to do things according to their own aesthetics.
We're enforcing whitespace around infix operators in Vale, and it's working pretty well. It's also enabling us to use <> for generics with no ambiguity =)
It should say base*exponent.
I think other languages use base^exponent, which would be fine with me too.