racket / htdp

Other
93 stars 70 forks source link

Comparison functions working on one argument seems counter-intuitive #185

Closed dbp closed 1 year ago

dbp commented 1 year ago

In BSL and above, numeric comparison functions (>, <, etc) inherit from racket/base the behavior that on a single argument, they always return true (as the arguments are in increasing/decreasing order).

This seems like pretty bad behavior for students, as it easily hides bugs: the student forgot the second argument to the comparison, and instead of getting an error, it silently returns #true every time.

(This actually came up in class -- when showing quicksort, I forgot the number when filtering elements using the pivot, so ended up with code like (filter (lambda (n) (< PIVOT)) lon) -- which ran fine, but returned the whole list).

mfelleisen commented 1 year ago

As much as I agree, I am not sure we can break backwards compatibility here. @rfindler what do you think? Do it for BSL only ? We impose restrictions on + too, and I can't recall the rationale for not imposing it on < and friends.

rfindler commented 1 year ago

I have wondered why we didn't impose this restriction for a few years now. Breaking old assignments and old lecture notes does seem worrying.

What about doing it only in #lang htdp/bsl Or perhaps all of those? Does that help?

Robby

On Mon, Nov 28, 2022 at 4:55 PM Matthias Felleisen @.***> wrote:

As much as I agree, I am not sure we can break backwards compatibility here. @rfindler https://github.com/rfindler what do you think? Do it for BSL only ? We impose restrictions on + too, and I can't recall the rationale for not imposing it on < and friends.

— Reply to this email directly, view it on GitHub https://github.com/racket/htdp/issues/185#issuecomment-1329859977, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADBNMHP7B4JUNNBW3BF6RLWKUZ6RANCNFSM6AAAAAASNTEHCU . You are receiving this because you were mentioned.Message ID: @.***>

mfelleisen commented 1 year ago

BSL only sounds right to me. I doubt any instructional material relies on that. — That won’t solve Daniel’s problem (with filter) but it’s a start.

rfindler commented 1 year ago

It seems like it would be nice to let people know this change was coming so they could comment or at least have time to prepare. (As opposed to having a student inform them that their lecture notes don't run or some equally pressured situation.)

I don't have any good ideas on how to reach people however. Twitter?

Robby

On Mon, Nov 28, 2022 at 5:47 PM Matthias Felleisen @.***> wrote:

BSL only sounds right to me. I doubt any instructional material relies on that. — That won’t solve Daniel’s problem (with filter) but it’s a start.

— Reply to this email directly, view it on GitHub https://github.com/racket/htdp/issues/185#issuecomment-1329892988, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADBNMGY3TXAURVICRFHDOTWKU77NANCNFSM6AAAAAASNTEHCU . You are receiving this because you were mentioned.Message ID: @.***>

mfelleisen commented 1 year ago

What’s Twitter? :-)

After some more thinking, I have come to the conclusion I should just go ahead and restrict < and friends. Nobody will rely on 1-arg variants. The question is whether I should also restrict the multi-arg (> 2) variants.

dbp commented 1 year ago

I think the benefit of getting rid of the 1 argument version is a lot more than the >2 one, even if in an ideal world, both were ruled out. So probably potentially breaking things isn’t worth doing the latter (the documentation is clear that > 2 args works, so it’s reasonable to expect some have done that, whereas only by looking at the core racket docs did I find the reference to single argument usage).

Though if #lang htdp/*sl are places where breaking changes can happen, could do both there?

On Mon, Nov 28, 2022, at 9:09 PM, Matthias Felleisen wrote:

What’s Twitter? :-)

After some more thinking, I have come to the conclusion I should just go ahead and restrict < and friends. Nobody will rely on 1-arg variants. The question is whether I should also restrict the multi-arg (> 2) variants.

— Reply to this email directly, view it on GitHub https://github.com/racket/htdp/issues/185#issuecomment-1329982552, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAELBJJFDVQQ2P6AFNZDHMTWKVQWFANCNFSM6AAAAAASNTEHCU. You are receiving this because you authored the thread.Message ID: @.***>