[Openmcl-devel] Extended-char is subtype of any other type

R. Matthew Emerson rme at acm.org
Thu Mar 2 09:03:19 PST 2017


> On Mar 2, 2017, at 2:58 AM, Renzo Orsini <renzo.orsini at gmail.com> wrote:
> 
> I found this strange behaviour when applying subtypep to extended-char:
> 
> $ ccl
> Welcome to Clozure Common Lisp Version 1.11-r16635  (DarwinX8664)!
> 
> CCL is developed and maintained by Clozure Associates. For more information
> about CCL visit http://ccl.clozure.com.  To enquire about Clozure's Common Lisp
> consulting services e-mail info at clozure.com or visit http://www.clozure.com.
> 
> ? (subtypep 'extended-char 'bit)
> T
> T
> ? (subtypep 'extended-char 'function)
> T
> T
> ? 
> … and similarly for many other types.

I'm not much of a language lawyer, but I think I can explain this.

Recall that a CL type is a set of objects.

In CCL, there is only one character type.  Thus, the set of objects denoted by the type (and character (not base-char)) contains no members.

The type that contains no objects is named nil.

(subtypep 'extended-char nil) => t, t
(subtypep nil 'extended-char) => t, t

This shows that, on CCL, extended-char and nil are two names for the same thing (the empty set in this case).

The type nil is a subtype of every type.  See http://www.lispworks.com/documentation/HyperSpec/Body/t_nil.htm

Thus, when you write (subtypep 'extended-char 'bit), it is as if you are writing (subtypep nil 'bit).  And (subtypep nil x) is t, t for any type x.

> 
> while the HyperSpec says (http://www.lispworks.com/documentation/HyperSpec/Body/t_extend.htm#extended-char):
> 
> The type extended-char is equivalent to the type (and character (not base-char)).

That entry also says:  The type extended-char might have no elements in implementations in which all characters are of type base-char.

I hope this explanation is correct and helpful.




More information about the Openmcl-devel mailing list