htdp
htdp copied to clipboard
in ASL `(void)` doesn't print as `(void)`
This also manifests itself (I think) as when
s 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)
.
More odd behavior related to this:
> (void? (set! x 1))
#false
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.
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...
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.
My guess is that when
is wrong and should be fixed.
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.
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.
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.
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.
That sounds like a “one point of control” fix.