[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
A type specifier question for the CL language theorists.
Date: Mon, 14 May 90 15:13:04 EDT
From: cogen@XN.LL.MIT.EDU (David Cogen)
I thought that (LIST INTEGER) was permissible.
But, there is another way to do this, although I suspect that most compilers
would ignore it. It uses SATISFIES.
The type is
(AND LIST (SATISFIES EVERY-INTEGER-P))
where EVERY-INTEGER-P is
(DEFUN EVERY-INTEGER-P (LIST)
(EVERY #'INTEGERP LIST))
-- David Cogen.
Yes, I will take your advice and write it just this way. Thanks.
I don't really care whether compilers ignore this or not (see below).
--------------------------------------------------------------------------------
Date: Mon, 14 May 90 15:58 EDT
From: Barry Margolin <barmar@Think.COM>
Date: Mon, 14 May 90 11:20 PDT
From: RDP@ALAN.kahuna.decnet.lockheed.com (Robert D. Pfeiffer)
I just realized that I don't know how to write a type specifier that
concerns itself with the types of the elements of a list. That is, I
can write '(ARRAY INTEGER) to specify an array that consists of
integers but I can't write '(LIST INTEGER) to do the same for lists.
Am I missing something obvious, or is there really no standard CL way to
do this?
There is no standard CL way to do this. The primary reason this exists
for arrays is because most implementations have specialized
representations of arrays with restricted element types (for instance,
(array (unsigned-byte 8)) can be implemented by packing four bytes into
a word and using byte addressing, rather than as an array of pointers as
in the general case), and code generation for array accessors can take
advantage of compile-time knowledge of the storage type. Lists are less
amenable to such storage optimization, since they still have to have the
cdr pointer (even in cdr-coded implementations they have to have a
full-sized car pointer that can be replaced with a forwarding pointer
when you rplacd).
I understand. The real issue here is that I want to use a type
specifier to "program my intent" for documentation purposes. As you
point out, the implementation of type specifiers in CL is really for
getting (allowing) compiler optimizations to happen.
By the way, general Common Lisp questions are better off being sent to
the common-lisp@sail.stanford.edu mailing list, rather than the slug
mailing list. The latter is more oriented towards Symbolics- and
user-group-specific discussions.
barmar
Thanks for pointing this out. I wasn't aware of this mailing list.
Date: Mon, 14 May 90 13:40 PDT
From: Stephen L. Nicoud <snicoud@atc.boeing.com>
Date: 14 May 90 20:19:39 GMT
From: barmar@Think.COM (Barry Margolin)
By the way, general Common Lisp questions are better off being sent to
the common-lisp@sail.stanford.edu mailing list, rather than the slug
mailing list. The latter is more oriented towards Symbolics- and
user-group-specific discussions.
The address is now common-lisp@mcc.com, although the sail.stanford.edu
address will work until that machine is finally turned off (it forwards
common-lisp mail to mcc.com). Requests to be added to Common Lisp list
should go to common-lisp-request@mcc.com.
Steve
--
Stephen L. Nicoud <snicoud@atc.boeing.com> uw-beaver!bcsaic!snicoud
Boeing Advanced Technology Center for Computer Sciences
And thanks for correcting the address. My request is on the way!