[racket] print semantics

From: Carl Eastlund (cce at ccs.neu.edu)
Date: Sun Feb 13 16:51:40 EST 2011

Anthony,

The Scheme standard specifies display and write, but not print.
Racket includes print as a more flexible output function that can be
customized in ways that need not conform to the standard for display
or write.  We recently updated the format of print's output in order
to make it concise as often as possible, easy to read both
s-expressions and user-defined structures as well as tell them apart,
and yes, to make it frequently evaluate back to the same result.  I
think the biggest benefit of that feature is that if you know how to
read Racket source code, you know how to read the output of print.
But if you don't like the default behavior of print for your own
programs, you can always use display or write, update the
current-print parameter, or install a prop:custom-write property value
for your structs.

Carl Eastlund

On Sun, Feb 13, 2011 at 3:58 PM, Anthony West
<anthony.west.513 at gmail.com> wrote:
> Dear PLT,
>
> I'm a bit puzzled by Racket's 'print', and I hope you can help me with a
> couple of questions:
>
> 1. How did the need arise for a printed representation that evaluates to
> something 'equal?' to the printed value?  Could you give an example to help
> me understand this?
>
> 2. Given that need, why did PLT depart from the Scheme standard and use
> 'print' for the new semantics?  Why not define another function that does
> the job (e.g., 'eprint')?
>
> Sorry if this post is noisy; I found no answers in the archives.
>
> Thank you,
> Anthony West



Posted on the users mailing list.