From: Vladimir Zolotykh
Subject: closures and methods
Date: 
Message-ID: <3C31F880.66043BEF@eurocom.od.ua>
Hi

Is it safe to make closure for a method ?
For example:

(let ((a 0))
(defmethod foo ((i fixnum))
  (incf a i))
)

Thanks

-- 
Vladimir Zolotykh                         ······@eurocom.od.ua

From: Kent M Pitman
Subject: Re: closures and methods
Date: 
Message-ID: <sfwvgellwyv.fsf@shell01.TheWorld.com>
Vladimir Zolotykh <······@eurocom.od.ua> writes:

> Is it safe to make closure for a method ?
> For example:
> 
> (let ((a 0))
> (defmethod foo ((i fixnum))
>   (incf a i))
> )

For it not to be, you'd have to find a restriction.  The language semantics
is not designed piecewise in the way your question implies.  LET just binds
variables.  DEFMETHOD just records information, some of which might create
closures implicitly.  Created closures might capture environment.  It's hard
to see how it could be gotten wrong by the implementation, but if it was
gotten wrong, a bug report should be submitted.

A question more commonly confusing to people is

 (let ((b 'bee))
   (defclass foo ()
     ((a :initform b))))

because I think some people imagine that the initform is a form to be
evaluated, but because the lexical environment of an initform is said to
be that of the defclass, it should be turned into #'(lambda () b) [and 
should funcalled] to capture and use the lexical B.
From: Tim Moore
Subject: Re: closures and methods
Date: 
Message-ID: <a0t0t2$g7m$0@216.39.145.192>
In article <·················@eurocom.od.ua>, "Vladimir Zolotykh"
<······@eurocom.od.ua> wrote:


> Hi
> Is it safe to make closure for a method ? For example:
> (let ((a 0))
> (defmethod foo ((i fixnum))
>   (incf a i))
> )
Yup.
> Thanks
No problem.

>