[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

list type cleanup



Issue:		LIST-TYPE-SPECIFIER
References:     CLtL, pg 26, 27, 43.
Category: 	Compatible Change
Edit History:   v0 28june88  mike beckerle


Problem Description:

There is a need in common lisp for more accurate type specifiers
for lists. In particular, there is no way to express
the type of a list having particular element types.

Resolving this issue will help resolve FUNCTION-TYPE-REST-LIST-ELEMENT.


Proposal: LIST-TYPE-EXTENDED

(1) The LIST type specifier would be extended to allow 
specification of arguments. e.g.,

(typep x 'list)  => unchanged from current meaning

(typep x '(list <subtype>)) == (and (typep x 'list)
                                    (typep (car x) <subtype>))

(typep x '(list <s1> <s2> ... <sN>)) ==
        (and (typep x 'list)
             (typep (car x) <s1>)
             (typep (cadr x) <s2>)
             ...
             (typep (car (last x)) <sN>))


Hence, the LIST type specifier is extended to allow specification of the
types of the arguments.

(2) A new type specifier is added: LIST-OF.

(typep x 'LIST-OF) = error.

(typep x '(list-of <elttype>)) == (and (typep x 'list)
	                               (dolist (elem x T)
				         (unless (typep x <elttype>)
                                            (return nil))))


Discussion:

The addition of these type specifiers allows resolution of the
FUNCTION-TYPE-REST-LIST-ELEMENT proposal in a way which will allow
type-specifiers to still be highly specific about the types of 
elements passed in &rest arguments.

In particular, (function (&rest (list-of number)) number), can be
distinguished from (function (&rest (list complex fixnum bignum))
number).





					       



-------