0.8.0.78.vector-nil-string.1:
authorChristophe Rhodes <csr21@cam.ac.uk>
Wed, 18 Jun 2003 15:16:05 +0000 (15:16 +0000)
committerChristophe Rhodes <csr21@cam.ac.uk>
Wed, 18 Jun 2003 15:16:05 +0000 (15:16 +0000)
commit902e93736a0888aa6b04dc328b1eb328423bf426
tree95989fd4f37eb79c2cc52368acb75b2d6faf6cbc
parent937a46e64983862cb9e21761db95e58700341940
0.8.0.78.vector-nil-string.1:
        As noted with horror between myself and pfdietz on #lisp,
        vectors specialized on NIL are strings.

This patch implements (VECTOR NIL) as subtype of STRING with no
regressions in either our regression test suite or pfdietz' test suite.

However, this notwithstanding, there are a number of issues that need to
be resolved before this hits HEAD.  (Why would it hit HEAD, you ask?
Well, it /is/ an ANSI issue, but in this case that would probably just
merit it an entry in BUGS, were it not for the fact that a Unicode
implementation is likely to have several string representations, so most
of the issues that we're addressing here will have to be dealt with in
any case; the use of (ARRAY NIL) as a "poison pill" to investigate
string routines and the like is probably a good thing.  Note that this
is only a half-way house; while STRING is no longer the same type as
BASE-STRING, which is one portion of the Unicode battle, CHARACTER
remains equivalent to BASE-CHAR).

Brokennesses:
* STRING= and similar functions may work by accident for (VECTOR NIL 0),
  but they're unlikely to be robustly working;
* FFI and ALIEN: we need at the very least (a) to ensure that C-STRINGs
  get turned into a useful string type, not (VECTOR NIL) and (b) to
  install a conversion routine for the other direction, so that the Lisp
  string #.(make-array 0 :element-type nil) becomes the C string "";
* Filesystem access and SB-UNIX is completely unaudited.  This may be
  similar to the above issue;
* SXHASH-SIMPLE-STRING tries to access string elements, and promptly
  errors on a (VECTOR NIL) with non-zero length.  This also breaks
  TYPE-OF;
* INTERN currently takes only a BASE-STRING;
* [ probably others.  Should examine Brian Spilsbury's Unicode patch for
    some more gotchas. ]

Suboptimalities:
* 10% slowdown in self-compilation, probably mostly caused by
  CONCATENATE (not transformed away for general SIMPLE-STRINGs any more)
  and HAIRY-DATA-VECTOR-{REF,SET} (type dispatch unavoidable for the
  latter on STRING-typed objects).  We can mitigate the latter issue by,
  for STRINGlike types including (VECTOR NIL), having a vector nil type
  test branching to an array-nil-accessed error clause if true, then
  retrying the hairy-data-vector optimization;
* throughout the codebase, string and base-string have been
  interchangeably used for a number of years; we need to look at them
  all and fix them if necessary.
36 files changed:
package-data-list.lisp-expr
src/code/array.lisp
src/code/class.lisp
src/code/defpackage.lisp
src/code/deftypes-for-target.lisp
src/code/interr.lisp
src/code/late-type.lisp
src/code/package.lisp
src/code/pred.lisp
src/code/primordial-extensions.lisp
src/code/room.lisp
src/code/seq.lisp
src/compiler/array-tran.lisp
src/compiler/fndb.lisp
src/compiler/generic/early-objdef.lisp
src/compiler/generic/genesis.lisp
src/compiler/generic/interr.lisp
src/compiler/generic/late-type-vops.lisp
src/compiler/generic/primtype.lisp
src/compiler/generic/vm-fndb.lisp
src/compiler/generic/vm-typetran.lisp
src/compiler/knownfun.lisp
src/compiler/seqtran.lisp
src/compiler/sparc/insts.lisp
src/compiler/x86/array.lisp
src/compiler/x86/c-call.lisp
src/compiler/x86/vm.lisp
src/runtime/alloc.c
src/runtime/backtrace.c
src/runtime/gc-common.c
src/runtime/gencgc.c
src/runtime/print.c
src/runtime/purify.c
src/runtime/runtime.c
src/runtime/search.c
version.lisp-expr