Runtime evaluation: Difference between revisions

Rename Perl 6 -> Raku, alphabetize, minor clean-up
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 371:
→ 42
</lang>
 
=={{header|Elena}}==
Using ELENA Script engine and VM client mode (3.3.0):
Line 625 ⟶ 626:
 
J relies on the OS for sandboxing and does not offer any additional resource constraints.
 
 
=={{header|Java}}==
Line 944:
CheckIt
</lang>
 
 
=={{header|Mathematica}}==
Line 1,205 ⟶ 1,204:
<lang perl>my ($a, $b) = (-5, 7);
$ans = eval 'abs($a * $b)'; # => 35</lang>
 
=={{header|Perl 6}}==
Any syntactically valid sequence of statements may be run, and the snippet to be run can see its outer lexical scope at the point of the <tt>eval</tt>:
<lang perl6>use MONKEY-SEE-NO-EVAL;
 
my ($a, $b) = (-5, 7);
my $ans = EVAL 'abs($a * $b)'; # => 35</lang>
Unlike in Perl 5, <tt>eval</tt> in Perl 6 only compiles and executes the string, but does not trap exceptions. You must say <tt>try eval</tt> to get that behavior (or supply a <tt>CATCH</tt> block within the text to be evaluated).
 
=={{header|PHP}}==
Line 1,396 ⟶ 1,387:
 
And, of course, both of these methods can use Racket's multilingual capabilities and evaluate the code in a language with different semantics.
 
=={{header|Perl 6Raku}}==
(formerly Perl 6)
Any syntactically valid sequence of statements may be run, and the snippet to be run can see its outer lexical scope at the point of the <tt>eval</tt>:
<lang perl6>use MONKEY-SEE-NO-EVAL;
 
my ($a, $b) = (-5, 7);
my $ans = EVAL 'abs($a * $b)'; # => 35</lang>
Unlike in Perl 5, <tt>eval</tt> in Perl 6 only compiles and executes the string, but does not trap exceptions. You must say <tt>try eval</tt> to get that behavior (or supply a <tt>CATCH</tt> block within the text to be evaluated).
 
=={{header|REBOL}}==
Line 1,618:
Likewise, the code compiled at runtime has access to not just variables, but also files, functions, etc., that are in the already-compiled program.
 
=={{Headerheader|Sparkling}}==
 
In Sparkling, the standard library provides functions to compile expressions and statements into functions. Each such function is considered a different top-level program, running in the execution context of it's "parent" program (i. e. the piece of code from within which it was created). Consequently, functions compiled at runtime share their environment (e. g. all globals) with their parent program.
10,333

edits