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


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:
	   you pass a float and a string to MY-CONS
	   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

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.