Runtime evaluation: Difference between revisions

Content added Content deleted
(Add Python)
(expand task a bit, mark incorrect existing lacks of input/output discussion)
Line 1: Line 1:
{{task}} 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.
{{task}} Demonstrate your language's ability for programs to execute other programs in the language provided at runtime. Show us what kind of program( fragment)s are permitted (e.g. expressions vs. statements), 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.
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.
Line 6: Line 6:


=={{header|ALGOL 68}}==
=={{header|ALGOL 68}}==

{{incorrect|ALGOL 68|It does not discuss passing in values.}}

<!-- {{does not work with|ALGOL 68|Standard - variable names are not visible at run time with classic compilers.}} -->
<!-- {{does not work with|ALGOL 68|Standard - variable names are not visible at run time with classic compilers.}} -->
{{works with|ALGOL 68G|Any - tested with release mk15-0.8b.fc9.i386 - this implementation is an interpretor, and ''evaluate'' is an extension to the standard}}
{{works with|ALGOL 68G|Any - tested with release mk15-0.8b.fc9.i386 - this implementation is an interpretor, and ''evaluate'' is an extension to the standard}}
Line 41: Line 44:


=={{header|Groovy}}==
=={{header|Groovy}}==
{{incorrect|Groovy|It does not discuss passing in or returning values.}}

This program evaluates the Groovy program solution to the "[[Yuletide Holiday]]" task:
This program evaluates the Groovy program solution to the "[[Yuletide Holiday]]" task:
<lang Groovy>new GroovyShell().evaluate '''
<lang Groovy>new GroovyShell().evaluate '''
Line 58: Line 63:


=={{header|Perl}}==
=={{header|Perl}}==
{{incorrect|Perl|It does not discuss passing in or returning values.}}

<lang perl>eval '4 + 5'</lang>
<lang perl>eval '4 + 5'</lang>


=={{header|Python}}==
=={{header|Python}}==
{{incorrect|Python|It does not discuss passing in or returning values.}}
<lang python>>>> exec '''
<lang python>>>> exec '''
x = sum([1,2,3,4])
x = sum([1,2,3,4])
Line 68: Line 76:


=={{header|Scheme}}==
=={{header|Scheme}}==
{{incorrect|Scheme|It does not discuss passing in or returning values.}}

This is very similar to the [[Eval#Common Lisp|Common Lisp]] above.
This is very similar to the [[Eval#Common Lisp|Common Lisp]] above.
<lang scheme>> (eval '(+ 4 5))
<lang scheme>> (eval '(+ 4 5))
Line 76: Line 86:


=={{header|Smalltalk}}==
=={{header|Smalltalk}}==
{{incorrect|Smalltalk|It does not discuss passing in or returning values, and it does not show taking in an arbitrary program as from user input.}}
<lang smalltalk>
<lang smalltalk>
[ 4 + 5 ] value.</lang>
[ 4 + 5 ] value.</lang>


=={{header|Tcl}}==
=={{header|Tcl}}==
{{incorrect|Tcl|It does not discuss passing in or returning values.}}
<lang tcl>
<lang tcl>
eval "expr {4 + 5}" ;# string input
eval "expr {4 + 5}" ;# string input