Runtime evaluation: Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
(New post showing the use of Java's REPL jshell. In addition to an existing post.)
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(4 intermediate revisions by 2 users not shown)
Line 434:
 
=={{header|Elena}}==
ELENA 56.0x:
Using ELENA Script engine:
<syntaxhighlight lang="elena">import extensions'scripting;
Line 440:
public program()
{
lscript.interpretinterpretLine("system'console.writeLine(""Hello World"")");
}</syntaxhighlight>
{{out}}
Line 690:
READ(FIle="my_file.txt", Row=6) string
XEQ( string ) ! executes row 6 of my_file.txt</syntaxhighlight>
 
=={{Header|Insitux}}==
 
All valid Insitux code can be evaluated at runtime using <code>eval</code>, including function definitions which remain in global scope, with access to global scope but not local.
 
<syntaxhighlight lang="insitux">
(var x 123)
[
(eval "(var y 100) (+ x y)")
y
]
</syntaxhighlight>
 
{{out}}
 
<pre>
[223 100]
</pre>
 
Error messages differ between normal code and evaluated code.
 
<b>Normal invocation error output:</b>
 
<pre>
1:6 (let time 1)
Parse Error: "time" cannot be redefined: already exists.
</pre>
 
<b><code>eval</code> invocation error output:</b>
 
<pre>
1:2 (eval "(let time 1)")
Eval Error: error within evaluated code.
Parse Error: 1695133413649 eval line 1 col 6: "time" cannot be redefined: already exists
</pre>
 
=={{header|J}}==
Line 2,018 ⟶ 2,053:
$ wren-cli
\\/"-
\_/ wren v0.34.0
> 20 + 22
42
Line 2,030 ⟶ 2,065:
 
Secondly, Wren has the ''Meta.eval'' method which can be used from within a script to execute any valid Wren code (presented to it in string form) at runtime. The string could be constructed within the script, obtained from a file or input by the user. Here's a very simple example:
<syntaxhighlight lang="ecmascriptwren">import "meta" for Meta
 
var s = "for (i in 0..4) System.print(i)"
9,483

edits