[racket] eval question

From: prad (prad at towardsfreedom.com)
Date: Thu Mar 31 12:49:53 EDT 2011

i'm trying to get a string to execute as a function.

====
#!/usr/bin/env racket
#lang racket

(define phr "THIS IS A PHRASE")
(define x "(display phr)")

(eval (read (open-input-string x)))
====

if i run the last line in the repl, it works.
however, if i just try to run the program i the following error:

compile: unbound identifier (and no #%app syntax transformer is bound)
at: display in: (display phr)

so it seems that it doesn't recognize the function "display".

is it not able to access the original namespace then?
what is the solution for doing something like this?

-- 
in friendship,
prad



Posted on the users mailing list.