[cmucl-imp] Lexical closures and FUNCALLABLE-STANDARD-CLASS
Mark Cox
markcox80 at gmail.com
Sun Jun 30 11:49:09 UTC 2013
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
More information about the cmucl-imp
mailing list