Archive for October, 2010

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

October 7, 2010

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

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.

Examples:

 (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"

--Q
Advertisements

Lisp implementors/maintainers poll

October 5, 2010

I’m working on my talk for the upcoming ILC. If you are the implementor or maintainer of a Common Lisp system, I’d love to know if you were involved in the standardization of Common Lisp either in the pre-ANSI period or on the ANSI committee. If you could drop me an email or leave a comment here, telling me who you are and saying whether you were or were not and what implementation you work on, that’d be a huge help. (If you were, please let me know if it was pre-ANSI, ANSI, or both.)