Anonymous user
Runtime evaluation: Difference between revisions
Add Jsish, shuffle Javascript and Julia entries back into alphabetical order
No edit summary |
(Add Jsish, shuffle Javascript and Julia entries back into alphabetical order) |
||
Line 722:
at Evaluator.eval(Evaluator.java:33)
at Evaluator.main(Evaluator.java:21)</pre>
=={{header|JavaScript}}==▼
The eval method handles statements and expressions well:▼
<lang javascript>▼
var foo = eval('{value: 42}');▼
eval('var bar = "Hello, world!";');▼
typeof foo; // 'object'▼
typeof bar; // 'string'▼
</lang>▼
From Javascript entry.
<lang javascript>/* Runtime evaluation, in Jsish */
var foo = eval('{value: 42}');
eval('var bar = "Hello, world!";');
;typeof foo;
;foo.value;
;typeof bar;
;bar;
/*
=!EXPECTSTART!=
typeof foo ==> object
foo.value ==> 42
typeof bar ==> string
bar ==> Hello, world!
=!EXPECTEND!=
*/</lang>
{{out}}
<pre>prompt$ jsish --U runtimeEvaluation.jsi
typeof foo ==> object
foo.value ==> 42
typeof bar ==> string
bar ==> Hello, world!</pre>
=={{header|Julia}}==
{{works with|Julia|0.6}}▼
To run an entire script in the current env:▼
<lang julia>include("myfile.jl")</lang>▼
To run a string in the current env:▼
<lang julia>include_string("""▼
x = sum([1, 2, 3])▼
@show x▼
""")▼
@show typeof(x) # Int64</lang>▼
=={{header|Kotlin}}==
Line 852 ⟶ 905:
<lang lua>f = load("return 42")
f() --> returns 42</lang>
▲=={{header|JavaScript}}==
▲The eval method handles statements and expressions well:
▲<lang javascript>
▲var foo = eval('{value: 42}');
▲eval('var bar = "Hello, world!";');
▲typeof foo; // 'object'
▲typeof bar; // 'string'
▲</lang>
▲=={{header|Julia}}==
▲{{works with|Julia|0.6}}
▲To run an entire script in the current env:
▲<lang julia>include("myfile.jl")</lang>
▲To run a string in the current env:
▲<lang julia>include_string("""
▲ x = sum([1, 2, 3])
▲ @show x
▲ """)
▲@show typeof(x) # Int64</lang>
=={{header|M2000 Interpreter}}==
|