Hi folks,
I've been wondering if there's any way to recall
(or get inside) an environment of a closure (= to
directly access variables bound to a closure)
And here's what I mean exactly:
(define ++ (let ((c 0)) (lambda()(set! c (1+ c))c)))
; we now have a closure
(procedure-environment ++)
;-> (
Hi,
"Maciek Godek" <[EMAIL PROTECTED]> writes:
> I've been wondering if there's any way to recall
> (or get inside) an environment of a closure (= to
> directly access variables bound to a closure)
Yes, with `the-environment':
guile> ((lambda (a b) (the-environment)) 2 3)
(((a b) 2 3) #)
B
2008/7/11 Ludovic Courtès <[EMAIL PROTECTED]>:
> "Maciek Godek" <[EMAIL PROTECTED]> writes:
>
>> I've been wondering if there's any way to recall
>> (or get inside) an environment of a closure (= to
>> directly access variables bound to a closure)
>
> Yes, with `the-environment':
>
> guile> ((lam
Ludovic Court?s:
"Maciek Godek" <[EMAIL PROTECTED]> writes:
I've been wondering if there's any way to recall
(or get inside) an environment of a closure (= to
directly access variables bound to a closure)
Yes, with `the-environment':
guile> ((lambda (a b) (the-environment)) 2 3)
(((a b)
On Fri, 11 Jul 2008, Kjetil S. Matheussen wrote:
>
>
> Ludovic Court?s:
> > "Maciek Godek" <[EMAIL PROTECTED]> writes:
> >
> >> I've been wondering if there's any way to recall
> >> (or get inside) an environment of a closure (= to
> >> directly access variables bound to a closure)
> >
> > Yes,
Kjetil S. Matheussen:
> The function "local-eval" is probably what you want.
>
> I use local-eval a lot, it's one of the really really
> nice features provided by Guile:
>
>
> (define-macro (with env . code)
> `(local-eval (quote (begin ,@code)) ,env))
>
>
> (define ++
> (let ((c 0))
>(c-dis