On Wed, Sep 28, 2011 at 10:36 AM, Marijn <hk...@gentoo.org> wrote:
>
> recent talk about internal define being considered the preferred style
> made me focus on trying to use it more in my own code and resulted in
> some thoughts which I'd like to throw out there without much sanity
> checking on my part.
>
> Consider:
>
> #lang racket
>
> (require racket/mpair)
>
> (let ((value-store (mlist (mcons 'variable #f))))
>  (define (variable-ref variable)
>    (massoc variable value-store))
>  (define (variable-set! variable value)
>    (set-mcdr! (variable-ref variable) value)))
>
> (variable-ref 'variable)

Try this:

#lang racket

(require racket/mpair racket/splicing)

(splicing-let ((value-store (mlist (mcons 'variable #f))))
 (define (variable-ref variable)
   (massoc variable value-store))
 (define (variable-set! variable value)
   (set-mcdr! (variable-ref variable) value)))

(variable-ref 'variable)
-- 
sam th
sa...@ccs.neu.edu

_________________________________________________
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users

Reply via email to