Runtime evaluation: Difference between revisions
+ blsq
(+ blsq) |
|||
Line 145:
Hello world!
</pre>
=={{header|Burlesque}}==
In Burlesque "Code" is actually just a list of identifiers. It is therefore possible to create and manipulate code at runtime.
Evaluating a block:
<lang burlesque>
blsq ) {5 5 .+}e!
10
</lang>
Creating code at runtime (changing map (+5) to map (+6) at runtime):
<lang burlesque>
blsq ) 1 10r@{5.+}m[
{6 7 8 9 10 11 12 13 14 15}
blsq ) 1 10r@{5.+}6 0sam[
{7 8 9 10 11 12 13 14 15 16}
</lang>
Code from string at runtime:
<lang burlesque>
blsq ) 1 10r@"5.+"psm[
{6 7 8 9 10 11 12 13 14 15}
</lang>
Evaluating strings at runtime (reverse is just for demonstration):
<lang burlesque>
blsq ) "[m}+.5{@r01 1"<-pe
{6 7 8 9 10 11 12 13 14 15}
</lang>
Injecting other functions into code:
<lang burlesque>
blsq ) {3 2}(?*)[+e!
6
</lang>
Identifiers not contained in a block require to be quoted to push them to the stack. Note the difference:
<lang burlesque>
blsq ) ?+
ERROR: Burlesque: (.+) Invalid arguments!
blsq ) ?+to
"Error"
blsq ) (?+)
?+
blsq ) (?+)to
"Ident"
</lang>
(also note the fallback to ''.+'' from ''?+'').
=={{header|Common Lisp}}==
|