Commit 138869ec9922f8ff72445fab5e7ee37ccb30a702

Thomas de Grivel 2015-03-30T10:00:44

Made can-rules-lambda into a function.

diff --git a/can.lisp b/can.lisp
index 51bba17..049a6d9 100644
--- a/can.lisp
+++ b/can.lisp
@@ -80,11 +80,17 @@
 	  (funcall can-lambda action object (or user :anonymous))
 	  (error "Please call CAN:COMPILE-RULES.")))
 
+    (defun can-rules-lambda ()
+      (let ((action (gensym "ACTION-"))
+            (object (gensym "OBJECT-"))
+            (user (gensym "USER-")))
+        `(lambda (,action ,object ,user)
+           (eq :can
+               (or ,@(mapcar (lambda (rule)
+                               (can/rule user action
+                                         object rule))
+                             *rules*))))))
+
     (defun compile-rules ()
       (setq can-lambda
-	    (compile nil `(lambda (action object user)
-			    (eq (or ,@(mapcar (lambda (rule)
-						(can/rule 'user 'action
-							  'object rule))
-					      *rules*))
-				:can)))))))
+	    (compile nil (can-rules-lambda))))))