From: David McClain
Subject: FORMAT and self modifying control strings
Date: 
Message-ID: <Lu2P7.11$PM.12268@news.uswest.net>
Hi,

I sat down tonight to write a simple routine -- print an item left justified
in a user specified width. After several hours spent studying the CLHS, I
seem unable to find anything comparable to the printf "*" specification....

I ended up having to use FORMAT to create a control string, on which an
outer FORMAT executes, e.g,

(defun print-width (str width)
  ;; print a string in the indicated minimum width
  (format t (format nil ·····@<~~A~~>" (or width 0)) str))


Surely there has to be a better way, using FORMAT!? Any hints? I was hoping
for something more like

(defun print-width (str width)
  ;; print a string in the indicated minimum width
  (format t "???"  (or width 0)) str))

where "???" contains the magic equivalent of "*" (asterisk).

- DM

From: Dr. Edmund Weitz
Subject: Re: FORMAT and self modifying control strings
Date: 
Message-ID: <m3k7w3jjdh.fsf@bird.agharta.de>
"David McClain" <······@qwest.net> writes:

> Hi,
> 
> I sat down tonight to write a simple routine -- print an item left justified
> in a user specified width. After several hours spent studying the CLHS, I
> seem unable to find anything comparable to the printf "*" specification....
> 
> I ended up having to use FORMAT to create a control string, on which an
> outer FORMAT executes, e.g,
> 
> (defun print-width (str width)
>   ;; print a string in the indicated minimum width
>   (format t (format nil ·····@<~~A~~>" (or width 0)) str))
> 
> 
> Surely there has to be a better way, using FORMAT!? Any hints? I was hoping
> for something more like
> 
> (defun print-width (str width)
>   ;; print a string in the indicated minimum width
>   (format t "???"  (or width 0)) str))
> 
> where "???" contains the magic equivalent of "*" (asterisk).
> 
> - DM

Isn't (format t ···@<~A~>" (or width 0) str) what you want or am I
missing something?

Edi.
From: David McClain
Subject: Re: FORMAT and self modifying control strings
Date: 
Message-ID: <TO3P7.40$p97.32798@news.uswest.net>
Dang!

"Dr. Edmund Weitz" <···@agharta.de> wrote
> Isn't (format t ···@<~A~>" (or width 0) str) what you want or am I
> missing something?

How did I miss that ~V !!!?  Of course this is what I wanted. Thanks!!

- DM
From: Kent M Pitman
Subject: Re: FORMAT and self modifying control strings
Date: 
Message-ID: <sfwk7w3cazd.fsf@shell01.TheWorld.com>
"David McClain" <······@qwest.net> writes:

> Dang!
> 
> "Dr. Edmund Weitz" <···@agharta.de> wrote
> > Isn't (format t ···@<~A~>" (or width 0) str) what you want or am I
> > missing something?
> 
> How did I miss that ~V !!!?  Of course this is what I wanted. Thanks!!

~V is not an op.  V is a parameter substitute, which says to take the 
parameter from the list of args.  It's really badly indexed partly 
because it's notationally obscure and it wasn't obvious how to index it.
People look for it under ~V but that's not the right place.  I should have
probably made a section for ~V that says:  "There is no ~V. See ..."

(I should have given these things names probably. Like "Pseudo-Parameters"
or "Variable-Parameters", so they had their own section and you were more
inclined to read about them.  As time went on I learned to name more and 
more paragraphs exactly in order to better index and call attention to their
content... but I didn't get to it here before we were done.)

Keeping in mind that the numbers 1 and 2 in ~1,2F are parameters, and that
the args ar the data you pass with the strings, then ~V,V says to grab those
two parameters for ~F from the arglist instead of the parameter list.

This _is_ all explained in CLHS, but if you're using a quickstart approach
that neglects to read the foundational information in 22.3, or if you're 
just skimming thinking you know what you're going to see, and you're not
really reading, you'll miss it.

WHILE WE'RE AT IT --->>>>  "#" is another thing that works like V that you
should know about eventually and might as well go learn about now.  It's also
got its uses and you're going to have missed that one, too, if you go 
searching for a solution to a problem rather than searching for this feature
in particular, because it won't present itself as the solution to your 
problem.  It'll just be a random little bit of trivia like "V" that you skim
past.  So do it now.  Go read the the header block of section 22.3.  It's
only about a page.  But you may find it a good use of time.
From: David McClain
Subject: Re: FORMAT and self modifying control strings
Date: 
Message-ID: <g_9P7.159$Ui5.279352@news.uswest.net>
 Hi Kent,

Yes I found the '#' operator, and I made good use of it for printing comma
and semicolon separated lists of items. I guess I found that because of the
examples making use of it. I did find the mention of V in the paragraph
describing the functional behavior of FORMAT. I only skimmed that section,
originally, and I was looking instead under the Operator sections for such
an item as V.

Thanks for all your incredible efforts in this CLHS. That must have occupied
you for quite some time!

- DM
From: Kent M Pitman
Subject: Re: FORMAT and self modifying control strings
Date: 
Message-ID: <sfwr8qa79sh.fsf@shell01.TheWorld.com>
"David McClain" <······@qwest.net> writes:

> Thanks for all your incredible efforts in this CLHS. That must have occupied
> you for quite some time!

Well, as mentioned in the document's credits, I did editing basically
full-time from about 1990 to 1994.  Before me, from 1987-1989, Kathy
Chapman from DEC did considerable setup work that served as a good
base for me to build from.  She, in turn, started from CLTL(1).

A great deal of Kathy's work was just restructuring Steele's book,
putting text into new places.  She was a very competent editor, but
wasn't a Lisp programmer, so some refinement had to follow.  But her
contribution, often overlooked, was still quite important.  And in
particular, one odd thing that was COMPLETELY important to the outcome
was that it was her decision to begin the task of slavishly using
\funref{...} and \conref{...} and \varref{...} in the TeX markup.
Lots of these had to be added later, but she got it going and I
inherited her markup decisions.  These all came out the same visually,
but she still tried to start the process internally.  I was not, at
the time, really sure what the point of that was, but I'm sufficiently
anal in my programming style that it suited me to make the notation
"just in case" and I used to refer to the document as "hypertext" long
before the idea of actually doing CLHS came up.  It just seemed to me
that it was cool that the document contained this extra information,
even if it was not being used.  I thought it might somehow be useful
for indexing one day.  But it suddenly became a key piece of core
value in CLHS when I wrote my TeX->HTML translator because it could
distinguish which of the many pages to take you to in many cases.
Sometimes the source contains more general markup because it's either
speaking ambiguously or because she or I was lazy that day.  But at
least a LOT of the cross-refs don't take you to ambiguity pages.  And
I credit Kathy for that very fortunate decision, which I honestly
doubt I'd have thought to make, at least at the time. Now that I
realize these things are issues, I'm much more sensitive to
them. Kathy also did the important work of getting a bunch of people
to agree on a bunch of nuissance issues about the general book design,
what was and wasn't a goal of the spec, etc.

There were also periodic guest editing services provided by Sandra
Loosemore (who tidied up the compilation section a great deal, in
particular) and Richard Gabriel (whose main interest was the CLOS
section, I think).  And then there were a number of people who read
large sections or whole drafts over and over and provides me with many
cubic feet of pages of comments to integrate.  And both Larry Masinter
and Guy Steele had a huge effect adminsitratively, even though not 
involved in the text.  I could go on...

I've found in my career that I'm often credited on some things for
more than I did, and I've learned to live with it without correcting
people every single little time, because on other things I'm credited
for far less than I did, and I suppose in some strange way it
balances.  And I certainly don't think of my contribution to the spec
was small, by any means, either in time, or in practical effect.  But
at the same time, I like to periodically remind people that it was a
true group effort involving awesome contributions by a lot of very
dedicated people.  So it's worth sometimes taking a moment to thumb
through the Credits section, which is detailed enough that if you spend
a couple minutes reading it, you can get a pretty good sense for some of
the other names who were involved.

So yes, it was an incredible effort.  But not just mine.  It was a
huge project.  And done almost entirely by email, btw, with only a
handful of in-person meetings.  The original CLTL design was a pretty
impreessive effort of similar kind.  Researchers from MIT's business
school actually studied the original CLTL design, making statistical
observations about the email and interviewing some parties (including
me) as part of a research project in the use of email as a medium,
years ago.  A paper called something like "Kneejerk Anti-LOOPism and
other Email Phenomena" resulted and was a nostalgic read.
 http://ccs.mit.edu/papers/CCSWP150.html