racket / rhombus

Rhombus programming language
Other
332 stars 59 forks source link

Make an RFC about Pyret-style binary operators #15

Closed jeapostrophe closed 1 month ago

jeapostrophe commented 5 years ago

(Parens are required unless all the operators are identical)

spdegabrielle commented 5 years ago

Edit: suggestion withdrawn — what about spaces? In Racket1 2/3 is ok, but 2+3 is not. Why not π*(r^2)*(h/3) ?

sorawee commented 5 years ago

@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.

spdegabrielle commented 5 years ago

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;

become

https://github.com/jeapostrophe/gamejam-2019/blob/master/mode-lambda.rkt

jackfirth commented 5 years ago

I find it hard to read infix math expressions without spaces, because usually multi-letter variables are used so everything looks scrunched together.

sorawee commented 5 years ago

-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.

spdegabrielle commented 5 years ago

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.

mflatt commented 1 month ago

527