You can do it using a simple macro

(define-syntax f
  (syntax-rules ()
    ((_ a n) (set! a n))))

(define p 1)
(f p 3)
p
> 3

(define r 5)
(f r 30)
r
> 30


Hari

----- Original Message -----
From: "Joe Snikeris" <[email protected]>
To: [email protected]
Sent: Sunday, August 8, 2010 9:59:41 PM GMT -05:00 US/Canada Eastern
Subject: [racket] Modifying bindings in parent environment

Hi all,

Is there a way for a procedure to modify bindings in it's parent
environment?  I suppose the technique would be similar to passing a
C-style pointer to the procedure.

For example:

(define p 1)
(f p 3)
p
> 3

Define f...

Thanks in advance,
Joe
_________________________________________________
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users
_________________________________________________
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users

Reply via email to