[racket] strange behavior

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Tue Jan 31 08:24:33 EST 2012

Let me suggest this: 

#lang racket

(define (main-of-your-program)
  (displayln (my-gensym))
  (displayln (my-gensym)))

(define my-gensym 0)

;; --- test: 
(require (only-in mzscheme fluid-let))
(define (generate-a-predictable-symbol) 'a0)
(fluid-let ((my-gensym generate-a-predictable-symbol))

The above used to work without the 'my-' prefix BUT we decided to make imports constant. 

-- Matthias

On Jan 31, 2012, at 7:38 AM, 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?
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users

Posted on the users mailing list.