[plt-scheme] Re: Novice question: evaluating symbols

From: Lee Spector (lspector at hampshire.edu)
Date: Fri Jan 8 10:44:32 EST 2010

I'm saying this from what I know is a low horse :-), but although I've been listening to stern lectures about overuse of eval for decades, and sometimes even giving them myself, I nonetheless find eval really useful in some situations. These include systems in which code is generated and evaluated dynamically (genetic programming systems, weird collaborative live-coding environments), one-off tasks in which I don't care about the overhead and don't want to have to implement a parser or syntax or even a table, and especially one-off tasks involving code that is generated and evaluated dynamically. I probably still overuse it, and I often revise code to eliminate it later, but I'm sure glad it's there.

As a relative newcomer to PLT I was happy to find that most of my eval-ing could be accommodated by adding something like this to my code:

(define-namespace-anchor my-anchor)
(define my-namespace (namespace-anchor->namespace my-anchor))

and then passing my-namespace as a second argument to eval.

For one of our recent projects (a weird collaborative live-coding environment) we also had to use "#lang scheme/load" and we had to fight with it a fair bit, but we got it mostly working.


On Jan 8, 2010, at 10:10 AM, Grant Rettke wrote:

> On Fri, Jan 8, 2010 at 8:17 AM, Robby Findler
> <robby at eecs.northwestern.edu> wrote:
>> Turning symbols into identifiers at runtime is fundamentally an
>> eval-like thing and should be avoided in any well-designed language
>> (to get in my high horse for a moment).
> Are there any good papers or posts on the topic?
> It might be interesting to see a list of the good uses...
> structure-related functions come to mind. Surely there are more?
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Lee Spector, Professor of Computer Science
School of Cognitive Science, Hampshire College
893 West Street, Amherst, MA 01002-3359
lspector at hampshire.edu, http://hampshire.edu/lspector/
Phone: 413-559-5352, Fax: 413-559-5438

Check out Genetic Programming and Evolvable Machines:
http://www.springer.com/10710 - http://gpemjournal.blogspot.com/

Posted on the users mailing list.