I’m trying to work out how scheme in general and racket in particular work.
I installed racket and started it up, and I get a two-pane window. I’ve noticed that using eval in the REPL thing in the bottom pane works, but if I try using it in the top half I get a cryptic error message:
#lang racket
(eval ’(+ 1 1))
gives:
+: unbound identifier;
also, no #%app syntax transformer is bound in: +
Is there some additional magic, or is this something I don’t need to worry about? How will a program be run in the competition?
Racket apparently has terrible namespace conventions. I had the same problem when I tried to use it to interpret a file, but when I type a program directly into the interpreter, eval works fine. I’ll either figure out how to get eval to work when I run a file, or I’ll just paste people’s programs into the interpreter. Either way, assume eval will work properly.
In both #lang racket and #lang scheme, (eval form) by itself apparently runs form in a basically empty namespace. I’ve personally been using the following incantation for evaluating anything in the “standard” namespace:
(define (ueval x)
(define ns (make-base-namespace))
(eval x ns))
Then (ueval source-code) evaluates source-code in a clean namespace with all the normal builtins, including eval.
I’m trying to work out how scheme in general and racket in particular work.
I installed racket and started it up, and I get a two-pane window. I’ve noticed that using eval in the REPL thing in the bottom pane works, but if I try using it in the top half I get a cryptic error message:
gives:
Is there some additional magic, or is this something I don’t need to worry about? How will a program be run in the competition?
Racket apparently has terrible namespace conventions. I had the same problem when I tried to use it to interpret a file, but when I type a program directly into the interpreter, eval works fine. I’ll either figure out how to get eval to work when I run a file, or I’ll just paste people’s programs into the interpreter. Either way, assume eval will work properly.
The Guide says:
and indeed it works.
In both
#lang racket
and#lang scheme
,(eval form)
by itself apparently runsform
in a basically empty namespace. I’ve personally been using the following incantation for evaluating anything in the “standard” namespace:Then
(ueval source-code)
evaluatessource-code
in a clean namespace with all the normal builtins, includingeval
.