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-display "env" (the-environment)) > (lambda() > (set! c (1+ c)) c)))
I don't actually get the line with c-display. Does it require any additional module? 'Cause it ain' workin' for me. (and besides what does it do? the remaining part works fine) > (++) > => 1 > (with (procedure-environment ++) (set! c 20)) > > (++) > => 20 I'm really impressed :) Great respect! I only wonder if there's a way to add a new variable to an existing closure, or to delete one. (not that I need it right now; but I imagine that it can be implemented quite easily and efficiently in C if the notion of closure is well-defined and explicit)