htdp icon indicating copy to clipboard operation
htdp copied to clipboard

in ASL `(void)` doesn't print as `(void)`

Open florence opened this issue 8 years ago • 10 comments

This also manifests itself (I think) as whens not printing anything.

Example:

> (void)
> (when false (void))
> (when true (void))
> (define x 0)
> (when true (set! x 1))
(void)
> (when false (set! x 1))
> 

I would expect every line (except the (define x 0)) to print (void).

florence avatar Mar 08 '16 16:03 florence

More odd behavior related to this:

> (void? (set! x 1))
#false

florence avatar Mar 08 '16 16:03 florence

I think the status here is that there are intentionally two separate "void" values in ASL. One is Racket's void, which doesn't print anything. The other is ASL's void, which does print. I believe this was done because we wanted (void) to show up when a set! happened in the REPL. So probably the issue here is that we don't want Racket's void? to leak into ASL. ... but then why is void? in the language? I'm not sure.

@mfelleisen hopefully remembers.

rfindler avatar Mar 08 '16 22:03 rfindler

Just my 2c, but I can't think of a good reason for using void? in ASL, assuming you're following the design recipe, that is...

stamourv avatar Mar 08 '16 22:03 stamourv

The issue here is that one of the voids prints as (void) and the other void doesn't print at all. So:

> (when false #f)
> (set! x 0)
(void)

And this behavior is confusing students.

I don't think the behavior void? is really that important (like stamourv says, you shouldn't need to call it at all), but when and set! should print the same thing.

florence avatar Mar 08 '16 23:03 florence

My guess is that when is wrong and should be fixed.

rfindler avatar Mar 08 '16 23:03 rfindler

I do not recall ever discussing void vs void.
It strikes me as rather odd to have this and to force students to write (begin (set! x ..) (void)).

I stopped using ASL in 2002/03, and I have not maintained it since. I know that Jay/Shriram used it and added features.

My guess is that nobody would mind if someone/I unified the two void values.

mfelleisen avatar Nov 14 '21 18:11 mfelleisen

I'm not 100% sure I'm remembering this properly but I think the idea with adding a second void was so that it would print in the REPL, so all the ways that the racket/base void leak out should be changed.

rfindler avatar Nov 14 '21 18:11 rfindler

HtDP/1e says that you make complete sense. It makes (void) explicit. And that makes complete sense: we wanted a visible return value for every expression, and set! is an expression.

mfelleisen avatar Nov 14 '21 19:11 mfelleisen

I wonder if we might, in today's racket, be able to work around this by changing the REPL printing instead of adding a new form of void.

rfindler avatar Nov 14 '21 19:11 rfindler

That sounds like a “one point of control” fix.

mfelleisen avatar Nov 14 '21 19:11 mfelleisen