[plt-scheme] Programatically Constructed Symbol Used As An Identifier???

From: Grant Rettke (grettke at acm.org)
Date: Sat Jun 27 09:23:22 EDT 2009

Hi Veer,

On Sat, Jun 27, 2009 at 1:40 AM, Veer<diggerrrrr at gmail.com> wrote:
> Your's and jos example is correct way to do what OP asked and
> I would have used the similar method as your's. I just observed that
> using eval also seems to work  :)  .

Indeed! :)

> I really don't know what top-level-form is , can you give an example
> of top-level-forms and not top-level-forms. I assume it is list of definitions
> or simply all forms which are not nested ,right or wrong?

The top level, I think, is simply anything not in a package. If you
enter in #lang scheme in the editor, hit F5, and then code like this
into the REPL and evaluate it.

> (define my-add +)
> (apply (eval 'my-add) '(1 2))

Eval works only in the top level only environment. If you tried it in
a module, it would not have my-add in its namespace. Paste this into
an editor and hit run:

#lang scheme
(define my-add +)
(display (apply (eval 'my-add) '(1 2)))

And you get the error:

compile: unbound identifier (and no #%top syntax transformer is bound)
in: my-add

Posted on the users mailing list.