31 Jan
2009
31 Jan
'09
20:11
On 31-Jan-09, at 7:49 PM, lowly coder wrote:
is there anyway i can obtain dynamic scoping in gambit? lexically scoping is really cool, and I want it as the default behavior; i just want the ability to go:
(define (foo x) (* x 2))
(define (g x) (foo x))
(pp (list (g 1) (dynamic-let ( (foo (lambda (x) (* x 3)))) (g 1))))
to get me:
(2 3)
This is the way you can do dynamic scoping in Gambit (and other Schemes too): (define foo (make-parameter (lambda (x) (* x 2)))) (define (g x) ((foo) x)) (pp (list (g 1) (parameterize ((foo (lambda (x) (* x 3)))) (g 1)))) You can also use dynamic-wind to simulate dynamic scoping but it does not work properly with threads. Marc