Lexical closures and FUNCALLABLE-STANDARD-CLASS

Mark Cox <[email protected]> Sun, 30 Jun 2013 21:49:09 +1000
Newsgroups gmane.lisp.cmucl.devel
Message-ID <[email protected]>
G'day,

Invoking a FUNCALLABLE-STANDARD-OBJECT which has the lexical closure created below as its function signals an error.

(defvar *a* nil)

(defclass something ()
  ()
  (:metaclass pcl:funcallable-standard-class))

(defun ensure-something (function)
  (let ((s (make-instance 'something)))
    (pcl:set-funcallable-instance-function s function)
    (setf *a* s)))

(let ((offset 1))
  (ensure-something #'(lambda (a)
			(+ offset a 3))))

(print (funcall *a* 3))
;; Should be 7.


Compiling and loading the above code (just loading is not enough) should produce the following error on CMUCL 20D x86 Darwin

Argument X is not a NUMBER: #<Closure Over Function "LET ((OFFSET 1))"
                              {49854C01}>.
   [Condition of type SIMPLE-TYPE-ERROR]

Thanks
Mark
_______________________________________________
cmucl-imp mailing list
[email protected]
http://lists.zs64.net/mailman/listinfo/cmucl-imp