[racket-dev] #true and #false

From: Eli Barzilay (eli at barzilay.org)
Date: Sun Oct 10 01:03:57 EDT 2010

Yesterday, Matthew Flatt wrote:
> At Fri, 8 Oct 2010 23:11:21 -0400, Eli Barzilay wrote:
> > Two hours ago, Matthew Flatt wrote:
> > > [Re-sending; an earlier post of this message seems to be delayed.]
> > > 
> > > What if the default printing format for true and false values in
> > > Racket changed from `#t' and `#f' to `#true' and `#false'?
> > > 
> > > The forms `#t', `#T', `#true', `#f', `#F', and `#false' would all be
> > > accepted as inputs forms. We could conceivably limit the change to
> > > `print' output and not change `write' or `display' output, but let's
> > > say for now that the proposal is to change the default for all
> > > output modes in Racket. [...]
> > 
> > I'd prefer it if at least `write' keeps it as "#t".  IMO `write' as a
> > quick way to serialize some data to a file in a way that is also
> > readable is a very big win, and having a single character (in addition
> > to the obligatory "#" syntax marker) used for booleans makes it fine
> > in most cases, even up to pretty big files.  I can see how making it
> > much longer will encourage using some bad home-cooked serializations
> > to avoid the extra size -- and that would be bad.
> I agree that serialization is a common use of `write', but if size
> is an issue, it seems like setting the `print-boolean-long-form'
> parameter would be easier than cooking a new serialization
> format.

The problem is that the number of hooks that you need to remember to
control IO keeps changing (and usually grows), making it hard to find.

> (Actually, `s-exp->fasl' and `fasl->s-exp' are better choices when
> size matters.)

(I should have added: "in a way that is also >>human<< readable and
editable".  The fasl formats are great for saving space and read time
(which is why I used that well before the fasl interface...), but I
use them only when the data is large enough to justify it -- otherwise
the editable format is a bigger win.)

> An even more common use of `write', I think, is to print code. If we
> switch to `#true' and `#false' as the default forms of the constants, I
> think we want all those uses of "~.s" that you recently fixed up to
> print with `#true' and `#false'.

Sounds like this is a core question then: I'd like to keep coding with
#t and #f, so I prefer seeing them in "~.s" messages.  Two points that
I see as emphasizing this: (a) it's a change that is motivated by the
teaching languages, (b) it contradics the gradual shift to avoiding
verbosity when possible (which is a direction that I very much like,
and I get the feeling that I'm not alone).

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

Posted on the dev mailing list.