I want to write the function "counted" that generates closures in
Scheme; I want that after this

   (define f (counted '(x) '(+ x x)))

f behaves like I wrote

  (define f (let((i 0))
              (lambda(x)            ;first argument
                (set! i (+ i 1))
                (display i)
                (+ x x))))          ;second argument

and to avoid symbols leaking which happens if I call

   (define f (counted '(i) '(+ i i)))

How would you do that "idiomatically"?

Is it possible to avoid symbol leaking relying only on lexical scope, without explicit alpha-conversion (gensym, built in or manual) and without macros?

Thanks
Kazimir Majorinc





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

Reply via email to