[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Issue: FUNCTION-TYPE-REST-LIST-ELEMENT, FUNCTION-DECLARATION issues
- To: cl-cleanup@SAIL.STANFORD.EDU, sandra%orion@CS.UTAH.EDU
- Subject: Re: Issue: FUNCTION-TYPE-REST-LIST-ELEMENT, FUNCTION-DECLARATION issues
- From: Pavel.pa@Xerox.COM
- Date: Wed, 2 Dec 87 21:42:47 PST
- In-reply-to: <871202-204108-1072@Xerox>
Larry says:
``I don't know what (declare (function my-cons (float string) list) ) means.''
It is usual in type theory for this to be read as an implication:
IF
you pass a float and a string to MY-CONS
THEN
MY-CONS is guaranteed to return a list.
More rigorously, a type theorist would see (function my-cons (float string)
list) as representing the set of all functions that, when applied to a float and
a string, return a list.
Under this view of types, we understand the constructor OR to be set-union (that
is, the type (OR t1 t2) represents the set of values in the union of the sets
represented by t1 and t2) and the AND constructor is thus set intersection.
Under this view, Nick Gall gives the wrong answer to his question about a
specific type for COPY-SEQ when he claims that a good one would be
(or (function (list) list)
(function (vector) vector))
Since this does not guarantee that COPY-SEQ will return a list when applied to a
list; in fact, a function in this type might very well bomb when presented with
a list. In general, ORing function types isn't very helpful. What he really
wants here is AND, not OR:
(and (function (list) list)
(function (vector) vector))
This represents the set of functions that both map lists to lists and vectors to
vectors.
Let me point out that I'm not claiming that this is how CLtL intends function
types to be interpreted, just that this meaning has proven very convenient for
most uses.
Pavel