Paul Dietz discovered that ANSI CL requires specialised arrays
with ARRAY-ELEMENT-TYPE NIL.
The consequences of this discovery are rather surprising, e.g.,
EQUAL stops being transitive.
Let
s = (make-array 0 :element-type 'character) = ""
b = (make-array 0 :element-type 'bit) = #*
n = (make-array 0 :element-type nil) = #A(NIL (0))
Then N is both a STRING (because NIL is a subtype of CHARACTER)
and a BIT-VECTOR (because NIL is a subtype of BIT).
ANSI CL spec for EQUAL says:
Two arrays are equal only if they are eq, with one exception:
strings and bit vectors are compared element-by-element (using eql).
therefore, both (EQUAL N S) and (EQUAL N B) must return T (or non-NIL).
OTOH, (EQUAL S B) must return NIL because S is not a BIT-VECTOR and
B is not a STRING, so the above rule does not apply,
(unless we interpret the spec to say that strings and bit-vectors
are compared between each other also).
Comments?
From: Kalle Olavi Niemitalo
Subject: Re: EQUAL is not transitive or (EQUAL "" #*) ==> T
Date:
Message-ID: <87smh9clol.fsf@Astalo.kon.iki.fi>
···@gnu.org (Sam Steingold) writes:
> Then N is both a STRING (because NIL is a subtype of CHARACTER)
> and a BIT-VECTOR (because NIL is a subtype of BIT).
I don't think that makes N a BIT-VECTOR. The definition of type
STRING explicitly mentions subtypes of CHARACTER, but the
definition of BIT-VECTOR doesn't mention subtypes of BIT.
From: Christophe Rhodes
Subject: Re: EQUAL is not transitive or (EQUAL "" #*) ==> T
Date:
Message-ID: <sqwu6k7kz4.fsf@lambda.dyndns.org>
···@gnu.org (Sam Steingold) writes:
> Paul Dietz discovered that ANSI CL requires specialised arrays
> with ARRAY-ELEMENT-TYPE NIL.
> The consequences of this discovery are rather surprising, e.g.,
> EQUAL stops being transitive.
> Let
> s = (make-array 0 :element-type 'character) = ""
> b = (make-array 0 :element-type 'bit) = #*
> n = (make-array 0 :element-type nil) = #A(NIL (0))
> Then N is both a STRING (because NIL is a subtype of CHARACTER)
> and a BIT-VECTOR (because NIL is a subtype of BIT).
No. Have a look at the descriptions of STRING and BIT-VECTOR again.
Christophe
--
http://www-jcsu.jesus.cam.ac.uk/~csr21/ +44 1223 510 299/+44 7729 383 757
(set-pprint-dispatch 'number (lambda (s o) (declare (special b)) (format s b)))
(defvar b "~&Just another Lisp hacker~%") (pprint #36rJesusCollegeCambridge)