From: Peter Seibel
Subject: Using a string as the destination arg to FORMAT
Date: 
Message-ID: <m3fz24fu3j.fsf@javamonkey.com>
The first argument to FORMAT can be a "string with a fill pointer" in
which case, according to 22.3, "the output is added to the end of the
string." In all the Lisp's I've tried, (Allegro 7.0, SBCL 0.8.16, and
CLISP 2.33.2) if the string is also adjustable FORMAT will extend it
but I can't find anywhere in the spec that requires that behavior. Am
I missing something or is this just a common understanding or just a
lucky chance that all those Lisp's do it the same way?

-Peter

-- 
Peter Seibel                                      ·····@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp
From: Duane Rettig
Subject: Re: Using a string as the destination arg to FORMAT
Date: 
Message-ID: <4k6rg77jn.fsf@franz.com>
Peter Seibel <·····@javamonkey.com> writes:

> The first argument to FORMAT can be a "string with a fill pointer" in
> which case, according to 22.3, "the output is added to the end of the
> string." In all the Lisp's I've tried, (Allegro 7.0, SBCL 0.8.16, and
> CLISP 2.33.2) if the string is also adjustable FORMAT will extend it
> but I can't find anywhere in the spec that requires that behavior. Am
> I missing something or is this just a common understanding or just a
> lucky chance that all those Lisp's do it the same way?

I think that your question centers around whether the output is being
done using VECTOR-PUSH or VECTOR-PUSH-EXTEND, which simply follows
from whether the string is adjustable or not.  Clearly, if the string
is not adjustable then it should not be adjusted when the array is
already full (but note from the description of MAKE-ARRAY that there
is really no way to portably require this anyway, since an array may
be actually adjustable even if it is not expressly adjustable).  On
the other hand, is there any reason to use vector-push when an array
is adjustable?

So how should we look at this?  I view it really as format's concept:
Most of the objects available as the first argument to fromat are
streams of some sort, and an adjustable array that does indeed get
adjusted might be thought of as a sort of stream-like thing.  So I
say that it is probably common philosophy that causes this kind of
behavior to be arrived at by several different implemetations.

You might be asking for a way to explicitly limit the output of the
stream.  This can't be done portably, since arrays not explicitly
adjustable may be actually adjustable, but in Allegro CL, the inspector
uses a simple-stream class (subclassed on string-output-simple-stream)
that limits the output to a certain length, and throws out (to allow
the rest of inspector code to be skipped) when the limit has been
exceeded.  The device-buffer-length method specifies how long the string
is to be.  Before we had simple-streams, we had a gray stream class that
exhibited the same behavior, with a different implementation.

-- 
Duane Rettig    ·····@franz.com    Franz Inc.  http://www.franz.com/
555 12th St., Suite 1450               http://www.555citycenter.com/
Oakland, Ca. 94607        Phone: (510) 452-2000; Fax: (510) 452-0182