Runtime evaluation: Difference between revisions
→{{header|Maxima}}
(Added Rebol code) |
|||
Line 751:
/* f(x) := x^2 + 1 */</lang>
=={{header|Oforth}}==
Oforth can evaluate strings at runtime.
In order to restrict evaluation, perform is used on strings. With perform, only objects can be evaluated. If a function or a method is included into the string an exception is raised and the function is not evaluated.
<lang Oforth>"[ [ $a, 12], [$b, 1.2], [ $c, [ $aaa, $bbb, $ccc ] ] ]" perform .s
[1] (List) [[a, 12], [b, 1.2], [c, [aaa, bbb, ccc]]]
"12 13 +" perform
[1:interpreter] ExCompiler : Can't evaluate <+></lang>
In order to evaluate any Oforth code, eval can be used. This method should not be used on unsafe strings.
<lang Oforth>"12 13 + println" eval
25
"func: newFunction(a) { a + } 12 newFunction(10) println" eval
22</lang>
=={{header|ooRexx}}==
|