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

commonlisp types

   Date: Fri, 2 Dec 1988 00:40-EST 
   From: Jamie.Zawinski <jwz@spice.cs.cmu.edu>
   Can someone explain the rationale behind forcing SATISFIES to 
   accept only function-names and not lambda expressions?
   I can see that the compiler could have special knowledge about
   such forms as (SATISFIES PLUSP), but CLtL says lambdas are excluded
   "to avoid scoping problems."


(defun bazola (linguini pop-tarts)
  (declare (type (satisfies (lambda (x) (< x linguini))) pop-tarts))

I'm trying to say that pop-tarts is always smaller in value than linguini.
The lambda expression appears lexically within the binding of linguini,
so one might expect that the free reference to linguini is legitimate.
But it can't work.

Similarly this cannot work:

(defun bazola (linguini pop-tarts)
  (assert (typep pop-tarts '(satisfies (lambda (x) (< x linguini)))))

[Of course, this can be rendered instead as

(defun bazola (linguini pop-tarts)
  (assert (< pop-tarts linguini))

but that is beside the point.]

One might conceivably argue that SATISFIES should allow an actual
function and not just a name; then one might try

(defun bazola (linguini pop-tarts)
  (assert (typep pop-tarts `(satisfies ,(lambda (x) (< x linguini)))))

but this approach doesn't help the declaration case.  It's a basic problem
of compile-time versus run-time execution.