[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Arrays and vectors (again)
- To: DLW at MIT-MC
- Subject: Arrays and vectors (again)
- From: Scott E. Fahlman <Fahlman at Cmu-20c>
- Date: Wed, 29 Sep 1982 00:53:00 -0000
- Cc: common-lisp at SU-AI
Well, the "RPG memorial" as it stands says that only strings can
be used as inputs to the special "string-specific" functions, but
your reply to me says that actually even non-simple char-arrays
can be used as inputs to the string functions.
The following text is lifted verbatim from the RPG memorial proposal:
"A STRING is a VECTOR whose element-type (specified by the :ELEMENT-TYPE
keyword) is STRING-CHAR. Strings are special in that they print using
the "..." syntax, and they are legal inputs to a class of "string
functions". Actually, these functions accept any 1-D array whose
element type is STRING-CHAR. This more general class is called a
Looks to me like I am saying that STRING-mumble accepts true strings and
also the more general CHAR-SEQUENCES. At least, that was what I was
trying to say. It just seemed too ugly to rename these functions
CHAR-SEQUENCE-mumble. I admit that the naming is confusing here, since
some objects other than stings are accepted by these functions, but this
seems no worse to me than Zetalisp's decision to let the string
functions accept symbols as well. The idea is that these are functions
that mostly work on strings and, as a special favor, they will also
swallow arbitrary 1-D arrays of characters.
Also, what does stringp do? Does it ever return t for anything with a fill
pointer? If so, then stringp returns t for things that are not strings,
which seems unacceptable; if not, then stringp will return NIL for some
things that print exactly the same way that strings print, and otherwise
behave very similarly, which seems undesirable.
In an implementation that distinguishes strings from char-sequences,
STRINGP would return T for true (simple) strings and NIL for everything
else. If you want to ask if something is a CHAR-SEQUENCE (which
includes strings as a subtype), you use CHAR-SEQUENCEP. It is true that
non-string char-sequences print as if they were strings, but I don't see
the problem with that, unless the association between STRINGP and the "..."
syntax has become sacred.