From: Christian Nyb�
Subject: Re: format question
Date: 
Message-ID: <87vgc2eom7.fsf@nybo.no>
Myriam Abramson <········@osf1.gmu.edu> writes:

> I want to do something like 
> 
> (setf symb 'object)
> (format nil "~R ~(~A~:P~)" 1 symb)
> 
> comes back as "one object".  It gives me "one objects".  I can't
> hardcode symb.
> 
> Looking at CLTL2, I don't see anyway to do what I want and I'm running
> out of time. Any ideas?

CL-USER(134): (format nil "~R ~(~A~:*~:P~)" 1 symb)
"one object"
CL-USER(135): (format nil "~R ~(~A~:*~:P~)" 2 symb)
"two objects"
CL-USER(136): 

The reason why your forms did not do what you expected, is that ~:P
refers to the last argument that was processed.  In your forms that
would be symb, which is not 1.  Therefore the s is affixed.  But if
you back up one place in the argument list with ~:*, you get what you
wish for.  If this is part of a large format string, you may want to
bypass the symb argument after adding the plural, like this;

CL-USER(142):  (format nil "~R ~(~A~:*~:P~* ~A~)" 1 symb "and a class")
"one object and a class"
CL-USER(143):  (format nil "~R ~(~A~:*~:P~* ~A~)" 2 symb "and a class")
"two objects and a class"
CL-USER(144): 
-- 
chr