[racket-dev] "~e" vs "~.s"

From: Eli Barzilay (eli at barzilay.org)
Date: Wed Aug 25 15:55:49 EDT 2010

Short version: I'm going to push a change for several "~e"s into
"~.s".  If I touched your code, it would be a good idea to check that
I did the right thing.

Long version:

Previously, "~e" was the right format string directive to use with
error values -- it is essentially "~v" (which uses `current-print')
but truncating the result to fit error messages.  The problem is that
in the racket language values are now printed with quotes, which
usually works fine (for most values), but sometimes the result is
strange (for many printouts of syntaxes).  For example, this:

  > (letrec ([x (delay (force x))]) (force x))
  force: reentrant promise 'x

is confusing in the obvious way.  The solution for such cases is to
use "~s" with the new modifier that truncates it: "~.s".  ("~e" is
therefore the same as "~.v", and "~.a" is something new that might be
fitting to show an error message inside another message.)  Being a
language in the Lisp family with the usual code=data thing, it is
obviously not always clear where "~.s" should be used.  My scan was
not very exact, likely to make a few mistakes and not change places
that should change, and still took forever.

So -- please tell me if you know about places with such bogus error
messages (or any other text), and have a look at the changes I did to
see that they're fine.

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

Posted on the dev mailing list.