-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 31-01-12 13:38, zermelo wrote: > I have the following problem. I want to replace procedure gensym > with a mock to test a piece of software with predictable gensym > values. When this is done, I restore the old gensym. Thus I wrote > this code in racket: > > (define old-gensym gensym) (define gensym <a mock ...>) ...test... > (define gensym old-gensym) > > but when I run it, I get "reference to an identifier before its > definition: gensym". On the other hand, if I write the same code in > the interaction window, everything works as expected. > > Is this a bug?
At the REPL top-level each define statement is evaluated in order, but in a module things work slightly differently. What you should prolly do is wrap ...test... in a (let ((gensym my-mock-gensym)) ...test... ). Another way to get what you want may be to use `set!' instead of `define' whenever you're REdefining something. Marijn -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.18 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk8n6QoACgkQp/VmCx0OL2yhuACeJh/0ccLpgYbeegZS6kZS/fpu t6QAn1KgKQtTs3lE/O4XqNp896KAiSqm =MJUL -----END PGP SIGNATURE----- ____________________ Racket Users list: http://lists.racket-lang.org/users