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

Re: Types of Functions

The problem is that the "function" types isn't a very good member of the
type lattice. For example, "functionp" is true of lists whose car is

In this case, "functionp" is a much more dynamic property. With most
data types,

(typecase x
   (regulartype ... compute ...   use x ... ))

the "use x" can assume that x is still "regulartype". This is currently
true of all types except those defined with "satisfies". In this
example, if "compute" were to (setf (car x) 'not-lambda), functionp
would no longer be true.

Given the existence of "satisfies" type specifiers, 

(deftype function () '(satisfies functionp))

Note also that symbols satisfy "functionp". ("functionp is always true
of symbols, lists whose car is the symbol lambda, any value returned by
the function special form, and any values returned by the function
compile... ").

This is dangerous to those who might write

(typecase foo
	(function ...)
	(symbol ...)

Finally, it is an implementation dependent type like "fixnum", whose use
is discouraged. Functions aren't a first-class type in Common Lisp, and
wishing it so (or allowing 'function in a typep) won't make it so.