On eval in dynamic languages generally and in Racket specifically (2011)
Published on: 2025-06-12 00:44:04
On eval in dynamic languages generally and in Racket specifically
posted by Matthew Flatt
The eval function is at the heart of a dynamic language, and it strikes many newcomers as an amazingly powerful tool. At the same time, experienced programmers avoid eval , because unnecessary use creates trouble. It’s not easy to explain why eval should be avoided or when it"s appropriate to use eval , but I’ll take another stab at it here.
What is eval ?
Consider the following “program” in English prose:
Assume that your favorite color is red. Now imagine a balloon that is your favorite color. Paint a canvas the same color as the balloon.
As English goes, that’s a fairly clear program with a fairly well-defined result. When I follow those instructions, at least, I will always produce a red canvas (assuming that I have a canvas and some red paint, but a potential lack of art supplies is not the point here).
I would come up with a red canvas even if I read the instructions when surrounded b
... Read full article.