Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

closure/defmethod question

7 views
Skip to first unread message

Bruce Lester

unread,
Mar 26, 2002, 9:19:45 PM3/26/02
to
Do the Common Lisp rules regarding closures and functions (defun) apply to
CLOS structures created with defmethod and defclass?

The following code behaves as I expect (the value of A is available to
closure-test) in LispWorks:

(let ((a 5))
(defmethod closure-test ((i integer))
(format t "I:~A A:~A~%" i a)))

Is this behavior a core part of Common Lisp that would work in other Common
Lisp implementations?


Rahul Jain

unread,
Mar 26, 2002, 10:08:52 PM3/26/02
to
"Bruce Lester" <bruce_...@email.com> writes:

> Do the Common Lisp rules regarding closures and functions (defun) apply to
> CLOS structures created with defmethod and defclass?

According to _The Art of the Metaobject Protocol_, the :initform args
close over the environment of the defclass form. I assume that this is
a requirement also present in the ANSI CL standard.

--
-> -/ - Rahul Jain - \- <-
-> -\ http://linux.rice.edu/~rahul -=- mailto:rj...@techie.com /- <-
-> -/ "Structure is nothing if it is all you got. Skeletons spook \- <-
-> -\ people if [they] try to walk around on their own. I really /- <-
-> -/ wonder why XML does not." -- Erik Naggum, comp.lang.lisp \- <-
|--|--------|--------------|----|-------------|------|---------|-----|-|
(c)1996-2002, All rights reserved. Disclaimer available upon request.

0 new messages