[racket] [plai] consistent output
At Sun, 20 Nov 2011 09:31:02 -0300, Eric Tanter wrote:
> By default, #lang plai prints out values as follows in the REPL:
>
> (define-type Foo
> (foo (x number?)))
>
> > (foo 1)
> (foo 1)
> > (list 1 2)
> '(1 2)
>
> The output is not really consistent, in that foo is printed as a (user-level)
> constructor, but list is not.
Well, `quote' is playing the role of constructor.
> For teaching, the problem with output '(1 2) is
> the need to explain (or try to ignore) the quote.
PLAI uses `quote' for lists starting on page 8, so if you're teaching
with the book, it may not be worthwhile to avoid `quote'.
I think my students has had little trouble with `quote'. In contrast,
in the bad old days when the `quote' was missing --- so that `(list 1
2)' printed as just `(1 2)' --- students had a difficult time with the
difference between expressions and printed values.
> If I change the output configuration to "constructor", then I get:
>
> > (foo 1)
> (make-foo 1)
> > (list 1 2)
> (list 1 2)
>
> Now list is printed as constructor, but foo is printed using its "low-level"
> constructor, which for teaching is not that great either.
Agreed --- this should be fixed.
Currently, constructor-style printing always uses a "make-", but the
default mode should be to use the same constructor name that `print'
uses when `print-as-expression' is true.
> The other option for output is "write", which gives:
>
> > (foo 1)
> #(struct:foo 1)
> > (list 1 2)
> (1 2)
>
> Again not so nice.
Agreed --- definitely not the right option for teaching.
> Basically, there seems to be no way to obtain:
>
> > (foo 1)
> (foo 1)
> > (list 1 2)
> (list 1 2)
>
> Is there?
Right -- not until we fix constructor-style printing.