[racket] Modifying bindings in parent environment

From: Hari Prashanth (krhari at ccs.neu.edu)
Date: Sun Aug 8 22:38:49 EDT 2010

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" <joe at snikeris.com>
To: users at racket-lang.org
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


Posted on the users mailing list.