racket / htdp

Other
91 stars 69 forks source link

Why are some functions coded as 2+ary and others 1+ary in BSL? #174

Closed jasonhemann closed 2 years ago

jasonhemann commented 2 years ago

I was surprised to see that in BSL + is defined an 2-or-more ary, but some other functions like <= are 1-or-more ary. Why? I'm sure there's a good reason for the discrepancy. But is the reason something better than just to show off that numeric functions can have different minimal arities? Is this just an artifact of the <=, etc. behavior being recently augmented for 8.6?

mfelleisen commented 2 years ago

Yes. (+ 1 2 3) is easy to understand. I have found (<= 1) is a source of errors.

rfindler commented 2 years ago

If you find (<= 1) to be a source of errors, why is allowed?

mfelleisen commented 2 years ago

It shouldn't but I guess we enabled it.

Backwards compatibility rules?

jasonhemann commented 2 years ago

I realize I'm not the primary audience, but I think I was more surprised by the discrepancy in behavior than I would have been by either choice consistently. FWIW, a couple of UG TAs were also in situ surprised by the discrepancy.

Do “backward compatibility” + “law of least surprise” now add up to an argument for making all the arithmetic primitives polyvariadic? Or would that be compounding a mistake?

rfindler commented 2 years ago

FWIW, I don't have a strong opinion here :)

mfelleisen commented 2 years ago

I do. I think functional but not error backwards compatibility must win for such things that instructors and teachers use.