rhombus-prototype icon indicating copy to clipboard operation
rhombus-prototype copied to clipboard

Make an RFC about Pyret-style binary operators

Open jeapostrophe opened this issue 6 years ago • 6 comments

(Parens are required unless all the operators are identical)

jeapostrophe avatar Jul 15 '19 14:07 jeapostrophe

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

spdegabrielle avatar Jul 15 '19 22:07 spdegabrielle

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

sorawee avatar Jul 15 '19 23:07 sorawee

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

spdegabrielle avatar Jul 15 '19 23:07 spdegabrielle

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

jackfirth avatar Jul 16 '19 00:07 jackfirth

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

sorawee avatar Jul 16 '19 02:07 sorawee

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.

spdegabrielle avatar Jul 16 '19 07:07 spdegabrielle