A krevitch to snork your flads: the lost ~U format directive

Preparing for my upcoming ILC talk led me to some old Common
Lisp email archives where I came across this proposal from Guy

Date: 11 June 1982 2233-EDT (Friday)
From: Quux
To: bug-lisp at MIT-AI, bug-lispm at MIT-AI, common-lisp at SU-AI
Subject:  Proposed new FORMAT operator: ~U("units")

Here's a krevitch that will really snork your flads. ~U swallows an
argument, which should be a floating-point number (an integer or ratio
may be floated first). The argument is then scaled by 10^(3*K) for
some integer K, so that it lies in [1.0,1000.0). If this K is suitably
small, then the scaled number is printed, then a space, then a
metric-system prefix. If not, then the number is printed in
exponential notation, then a space. With a :, prints the short prefix.


 (FORMAT () "~Umeters, ~Uliters, ~:Um, ~:UHz" 50300.0 6.0 .013 1.0e7)
  =>  "50.5 kilometers, 6.0 liters, 13.0 mm, 10.0 MHz"

And you thought ~R was bad!

Later he made this small addition:

Date: 12 June 1982 1119-EDT (Saturday)
From: Quux
To: bug-lisp at MIT-AI, bug-lispm at MIT-AI, common-lisp at SU-AI
Subject:  More on ~U (short)

I forgot to mention that the @ flag should cause scaling by powers of 2^10
instead of 10^3:

(format () "~Ubits, ~:Ub, ~@Ubits, ~:@Ub" 65536 65536 65536 65536)
  =>  "65.536 kilobits, 65.536 Kb, 64.0 kilobits, 64.0 Kb"


9 Responses to “A krevitch to snork your flads: the lost ~U format directive”

  1. rbpasker Says:

    my flads are suitably snorked!

  2. Chris Perkins Says:

    The ~U format directive reminds me of Frink ( http://futureboy.us/frinkdocs/ ), which is the only programming language to excite me since Common Lisp. I’ve been meaning to write some sort of Frink-like library or toy for CL when I get some free time, which means never.

    I hope my flads recover soon.

  3. Andy Wingo Says:

    Very amusing!

  4. Dan Weinreb Says:

    When I first created “format” by adapting Multics’s ioa_, I had no idea that I was releasing a flood of creativity. I was at the OOPSLA last year, and someone giving a talk was criticizing the complexity of Lisp’s “format”, and I piped up and said “mea culpa”, although the real hair is from Steele. I continue to be dubious about the iteration construct.

    However, this proposed ~u is completely in line with what format is for: formatting things, especially numbers.

    I wonder why we didn’t accept it?

  5. Peter Seibel Says:

    Hi Dan, I didn’t realize you were the father of FORMAT. Anyway, I think the iteration construct is the feature of FORMAT I use most often, possibly edged out by ~:d to get a commafied number.

  6. drj11 Says:


    It typifies the baroqueness of that section of Common Lisp, I too wonder why it didn’t get blessed by the standard.

    Doesn’t work so well for higher-dimensional units:

    1,000,000 m² = 1 km² (not 1 Mm² which is what ~U would give me).

    • Peter Seibel Says:

      drj11, I’m pretty sure that could be handled by allowing a numeric argument to the directive.

      (format nil “~2:um^2” (expt 10 6)) ==> “1 km^2”

      (format nil “~3:um^3” (expt 10 9)) ==> “1 km^3”


  7. If you thought printf was complicated… | Computer Stone Age Says:

    […] via Peter Seibel, who has much more context on his blog post. Like this:LikeBe the first to like this. […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

%d bloggers like this: