chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] dynamic scoping


From: Patrick Useldinger
Subject: Re: [Chicken-users] dynamic scoping
Date: Wed, 26 Jun 2013 23:54:25 +0200
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130509 Thunderbird/17.0.6

On 26/06/2013 23:47, Daniel Ajoy wrote:
"add" binds a to 1 at the moment of definition.

#;48> (define a 1)
#;49> (define (add x) (+ x a) )
#;50> (add 10)
11
#;51> (let ((a 100) ) (add 10) )
11

Is there a way to give a different value of "a" to add, so that,
something like this happens:

(let ((a 100) ) (add 10) )
110

(define a (make-parameter 1))
(define (add x) (+ x (a)))
(add 10)
(parameterize ((a 100))
  (add 10))
(add 10)

yields
11
110
11





reply via email to

[Prev in Thread] Current Thread [Next in Thread]