[racket] Modifying bindings in parent environment
On 09.08.10 03:59, Joe Snikeris wrote:
> 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
Something like this?
#lang racket
(define-syntax-rule (make-accessor b)
(case-lambda
[() b]
[(v) (set! b v)]))
(define (f x y)
(let ([old-x (x)])
(x y)
(list old-x (x))))
(let ([b 15])
(list b
(f (make-accessor b) 3)
b))
--
regards,
Jakub Piotr Cłapa