[plt-scheme] Eq bindings at different phase levels?

From: Remco Bras (vrsoft at gmail.com)
Date: Sat Feb 20 08:21:27 EST 2010

Hi,

I'm experimenting with a macro that requires access to a binding at
both run-time and expand-time.
Defining the binding two times, once with define and once with
define-for-syntax, will not do what I want since I need both bindings
to refer to the same mutable hash table.

I've tried the following, which puts the hash table in a module and requires it:

(module foo scheme
       (provide baz)
       (define baz (begin
                     (printf "Defining baz~n")
                     (make-hasheq))))

(require 'foo
        (for-syntax 'foo))

However, if the require is run, "Defining baz" is printed twice, and
the bindings for baz at phase level 0 and 1 refer to different hash
tables.
Is there a way to have these bindings refer to the same hash table?

-Remco


Posted on the users mailing list.