Next | Higher-Order Parsing | 9 |
Suppose we want to read a web user's input
It will be a mathematical function, like
(x^2 + 3*x)* sin(x * 2) + 14
We will emit a web page with a graph of their function
In Perl, there is an easy solution:
Use eval to turn the input string into compiled Perl code
You could imagine something similar for almost any language:
Write out a source code file with a suitable function in it
Embed the user input in the appropriate place in the file
Compile the file and execute the resulting binary
Next | Copyright © 2007 M. J. Dominus |