'eval' statement works well on command line of DrRacket (as mentioned on https://docs.racket-lang.org/guide/eval.html ):
> (eval '(+ 1 2))
However, if kept in the script file (main area of DrRacket) and run, it produces error:
(eval '(+ 1 2))
+: unbound identifier;
also, no #%app syntax transformer is bound in: +
Where is the problem?
In Racket, this is the correct way to run
eval inside a script:
(define-namespace-anchor a) (define ns (namespace-anchor->namespace a)) (eval '(+ 1 2) ns) => 3
Please refer to the documentation.