> On Oct 19, 2018, at 12:18 AM, Thomas Gilray <thomas.gil...@gmail.com> wrote:
> 
> I've tracked down a strange bug in my code to this behavior (minimized):
> 
> (define (my-eval e)
>   (parameterize ([current-namespace (make-base-namespace)])
>     (namespace-require 'racket)
>     (eval (compile e)))))
> (pretty-print (equal? (my-eval '(set 1)) (my-eval '(set 1))))
> 
> Which yields #f in Racket 6.12. If I print the values, or save and introspect 
> on them in various ways, they do appear they should be equal? but are 
> apparently not. If I just (compile (eval ...)) those expression then they are 
> equal?, so it appears it may have something to do with how the namespace is 
> setup.

Yes, it has to do with how the namespaces (there are two of them in your 
example) are setup. If you put the two expressions in the same namespace, then 
they are equal:

#lang racket
(define my-ns (make-base-namespace))
(define (my-eval e)
  (parameterize ([current-namespace my-ns])
    (namespace-require 'racket)
    (eval (compile e))))
(pretty-print (equal? (my-eval '(set 1)) (my-eval '(set 1))))
;=> #t

This is different because in your example, `(make-base-namespace)` was 
evaluated twice to create two different namespaces, where in this one 
`(make-base-namespace)` was evaluated only once, so both eval calls are in the 
same namespace.

Alex Knauth

> --
> Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to