[racket] splicing internal define?

From: Marijn (hkBst at gentoo.org)
Date: Thu Sep 29 03:36:38 EDT 2011

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hey Sam,

On 09/28/11 16:42, Sam Tobin-Hochstadt wrote:
> On Wed, Sep 28, 2011 at 10:36 AM, Marijn <hkBst at 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)

Thanks , that sure is nice! One nitpick: DrRacket (yesterday's git)
wants to indent it like so:

(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)))

Marijn
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk6EIAYACgkQp/VmCx0OL2w+kACfc9wKWZ/qdB+EojzlJUwLVsG0
gCMAoJZD/xo8Uhw22l0IugOHjZ21wP/q
=jfS4
-----END PGP SIGNATURE-----


Posted on the users mailing list.