Make an RFC about Pyret-style binary operators
(Parens are required unless all the operators are identical)
Edit: suggestion withdrawn
—
what about spaces?
In Racket1 2/3 is ok, but 2+3 is not.
Why not π*(r^2)*(h/3) ?
@spdegabrielle / in 2/3 is not an operator. 2/3 is a value, referring to the fraction whose numerator is 2 and denominator is 3. There's no computation to be done. It's not a compound expression.
In fact, who said that + needs a space: 1+2i in Racket works due to the same reason: + in 1+2i is not an operator. 1+2i is a value, referring to the complex number whose real part is 1 and imaginary part is 2. There's no computation to be done. It's not a compound expression.
But what is 2+3 or π*(r^2)*(h/3)? This is not a value. There is a computation left to be done, to reduce the expression down into a simpler form.
That's why 2/3 and 1+2i are ok, but 2+3 and π*(r^2)*(h/3) are not.
Also FYI: Pyret supports 2/3 as well.
Edit: suggestion withdrawn — I'm suggesting Racket2 infix expressions should be sans spaces, so and a/b can be read as an expression, not simply as a value.
e.g. in Racket2, the Racket1 expressions;
-
(* -0.15 ACTOR-SIZE) -
(/ x (* HEIGHT BORDER 2))
become
-
-0.15*ACTOR-SIZE -
x/(HEIGHT*BORDER*2)
https://github.com/jeapostrophe/gamejam-2019/blob/master/mode-lambda.rkt
I find it hard to read infix math expressions without spaces, because usually multi-letter variables are used so everything looks scrunched together.
-0.15*ACTOR-SIZE
Why does it read as -0.15 * ACTOR-SIZE rather than -0.15 * ACTOR - SIZE, which is a compile error?
More generally, possible identifiers will diminish greatly if we don't mandate whitespace. You can't write for/list anymore-- is that for divided by list or an identifier for/list? Same for let-values, define+provide, for* etc.
Pyret mandates whitespace due to the same reason.
Thanks for the feedback @sorawee @jackfirth Removing white space has a negative effect on readability. I think preferential matching of identifiers is possible, but is likely to cause hard to debug errors.