I should have clarified that I have a little exceptional environment (#%top override), and the dynamic evals used to work in the default environment, like you said. I can't change it back to default, though, so I need some other solution. The examples in the manual don't seem to quite deal with this kind of case.
I tried for example the following: ((lambda () (define ns (make-base-namespace)) ; create a new namespace? (current-namespace ns) ; apply it to take effect before the next lines define? (define x 5) (eval '(list 1 2) ns) >> ( 1 2) x >> 5 (eval '(list 1 2 x) ns))) >> reference to undefined identifier: x I'll next look into racket/load, thanks. br, jukka > -----Original Message----- > From: Ryan Culpepper [mailto:[email protected]] > Sent: 05 November 2010 18:04 > To: Jukka Tuominen > Cc: [email protected] > Subject: Re: [racket] Making namespaces meet > > > On 11/05/2010 05:53 AM, Jukka Tuominen wrote: > > > > Hi, > > > > I'm having trouble of getting namespaces meet when making dynamic > > definitions. I made a simple example below. > > > > ((lambda () > > (define x 10) > > (eval (list 'define 'y 5)) > > (+ x y))) > > > > ;>> reference to undefined identifier: y > > > > > > > > I then tried to "store" one of the namespaces and pass it on to > another, but > > I guess that's not the way the namespaces work. > > > > > > > > ((lambda () > > (define namespace (current-namespace)) > > (define x 10) > > (eval (list 'define 'y 5) namespace) > > (+ x y))) > > > > ;>> reference to undefined identifier: y > > > > > > Any ideas how to solve this? > > Both of your examples work at the racket repl. They should also work at > the DrRacket repl. They fail only when you put them inside of a module > (eg, the DrRacket definitions window after #lang racket), because a > module must have no free references when it is compiled, even if those > references would be defined during the execution of the module. > > Read reflection chapter of the Guide for more information: > > http://docs.racket-lang.org/guide/reflection.html > > The short answer is that to make DrRacket's definitions window act more > like an ordinary repl, use the racket/load language. That is, change > #lang racket to #lang racket/load. It seems you'll have to print out the > results yourself, though; racket/load doesn't do it automatically. > > Ryan _________________________________________________ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/users

