On 30 August 2010 23:37, Pascal J. Bourguignon <pjb@...> wrote:
> I don't buy it.
> If ecl and clisp can do it, why not sbcl?
The thing to note here is that in SBCL
(upgraded-array-element-type 'base-char) => BASE-CHAR
(upgraded-array-element-type 'character) => CHARACTER
whereas in Clisp the answer to both is CHARACTER. (I don't know about ECL.)
Now, given this, consider that CLHS *print-readably* says:
"If *print-readably* is true, some special rules for printing objects
go into effect. Specifically, printing any object O1 produces a
printed representation that, when seen by the Lisp reader while the
standard readtable is in effect, will produce an object O2 that is
similar to O1."
Similarity for arrays is defined thusly:
" Two one-dimensional arrays, S and C, are similar if the length of
S is similar to the length of C, the actual array element type of S is
similar to the actual array element type of C, and each active element
of S is similar to the corresponding element of C.
Two arrays of rank other than one, S and C, are similar if the
rank of S is similar to the rank of C, each dimension of S is
similar to the corresponding dimension of C, the actual array
element type of S is similar to the actual array element type of C,
and each element of S is similar to the corresponding element of C.
In addition, if S is a simple array, then C must also be a simple
array. If S is a displaced array, has a fill pointer, or is actually
adjustable, C is permitted to lack any or all of these qualities."
So, given that base-strings are have a different element-type from
(write (coerce string '(simple-array base-char (*)) :readably t)
must produce output that will be read back in as a base-string, and
(write (coerce string '(simple-array character (*)) :readably t)
must produce output that will be read back in as a "full" character string.
Since SBCL by default reads "FOO" as a full string (and not a
base-string limited to Latin-1 range), either the :readably t form for
base-strings must be different (as proposed, but not currently
implemented), or we are required to signal an error.
PS. We need a FAQ, and this should be one entry in there.