Runtime evaluation: Difference between revisions
(new task for all-about-eval (sorry, don't have time to write any examples yet)) |
(Added Common Lisp section) |
||
Line 4:
For a more restricted task, see [[Eval in environment]].
=={{header|Common Lisp}}==
==Using a list to represent code==
<lang lisp>(eval '(+ 4 5)) ; Evaluate the program (+ 4 5)</lang>
==Using a String to represent code==
<lang lisp>(eval (read-from-string "(+ 4 5)")) ; Evaluate the program (+ 4 5)</lang>
|
Revision as of 15:35, 22 April 2009
You are encouraged to solve this task according to the task description, using any language you may know.
Demonstrate your language's ability for programs to execute other programs in the language provided at runtime. Show us how you get values in and out (e.g. environments, arguments, return values), and what facilities for restricting (e.g. sandboxes, resource limits) or specializing (e.g. debugging facilities) the execution.
You may not invoke a separate evaluator program, or invoke a compiler and then its output, unless the interface of that program, and the syntax and means of executing it, are considered part of your language/library/platform.
For a more restricted task, see Eval in environment.
Common Lisp
Using a list to represent code
<lang lisp>(eval '(+ 4 5)) ; Evaluate the program (+ 4 5)</lang>
Using a String to represent code
<lang lisp>(eval (read-from-string "(+ 4 5)")) ; Evaluate the program (+ 4 5)</lang>