[racket] splicing internal define?

From: Eli Barzilay (eli at barzilay.org)
Date: Fri Sep 30 07:55:35 EDT 2011

Yesterday, Marijn wrote:
> > Incidentally, Marijn, given that that's a module right there, I
> > suspect that the main reason you want to hide "value-store" like
> > this is if this code was actually the result of a macro expansion.
> 
> This code is the result of macro expansion, local to the code
> produced by the macro and because the macro is looking to become
> rather large, I wanted to hide the implementation of value-store
> from the local uses as well. [...]

BTW, if you have a toplevel definition with a name that is introduced
hygienically, then it's already hidden, for example:

  #lang racket
  (define-syntax-rule (defcounter name)
    (begin (define c 0)
           (define (name) (set! c (add1 c)) c)))
  (defcounter a)
  (defcounter b)
  (defcounter c)
  (list (a) (b) (c) (c) (b) (a))

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!


Posted on the users mailing list.