[racket] On (void) and interactions
The #lang racket void is not the same thing as the void that comes out
of (say) intermediate's assignments and definitions. I'm not sure what
the intended behavior is but if you supply a small, complete example
that would probably help someone figure out if you're seeing a bug in
a printer or just the expected behavior.
Robby
On Thursday, May 26, 2011, Stephen Bloch <sbloch at adelphi.edu> wrote:
> I'm playing with encapsulated state in Advanced Student Language, and have noticed that sometimes I see "(void)" explicitly as a result in the interactions pane, and other times I see nothing at all.
>
> Specifically, I was playing with two different ways to implement a posn with its own "swap" and "format" methods. One way, storing the methods as fields of a struct, I get the following behavior:
>
>> (define here (build-with-swapper-and-formatter 3 4))
>> (define there (build-with-swapper-and-formatter 5 -2))
>> (my-posn-x here)
> 3
>> (my-posn-y there)
> -2
>> ((my-posn-formatter here))
> "(3, 4)"
>> ((my-posn-swapper here))
>> ((my-posn-formatter here))
> "(4, 3)"
>
> Note the lack of any visible result after the call to (my-posn-swapper here).
>
> The other approach, wrapping everything up in a function that dispatches on its argument, gives me the following behavior:
>
>> (define here (make-my-posn 3 4))
>> (define there (make-my-posn 5 -2))
>> (here 'x)
> 3
>> (there 'y)
> -2
>> (here 'format)
> "(3, 4)"
>> (here 'swap)
> (void)
>> (here 'format)
> "(4, 3)"
>
> Note that this time the "swap" produced an explicit "(void)".
>
> When does "(void)" print out, and when does it not? Why?
>
>
> Stephen Bloch
> sbloch at adelphi.edu
>
>
> _________________________________________________
> For list-related administrative tasks:
> http://lists.racket-lang.org/listinfo/users
>