[racket] [plai] consistent output

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Mon Nov 21 07:50:35 EST 2011

>From your email below, Matthew, I get the impression that you think some of
this can't be fixed inside the PLAI language itself, because there's no
other option at the Racket level. Is that correct?

Jay

On Sun, Nov 20, 2011 at 7:48 AM, Matthew Flatt <mflatt at cs.utah.edu> wrote:

> 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.
>
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users
>



-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay

"The glory of God is Intelligence" - D&C 93
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20111121/17f6e244/attachment.html>

Posted on the users mailing list.