Jump to content

Runtime evaluation/In an environment: Difference between revisions

m
→‎{{header|Factor}}: tone down some snark
m (→‎{{header|Factor}}: remove some whitespace)
m (→‎{{header|Factor}}: tone down some snark)
Line 251:
 
=={{header|Factor}}==
Being a stack-based language, there is usually no need to bind data stack objects to a variable name. This is the idiomatic way to do it, with <code>eval</code> referencing what it needs from the data stack:
<lang factor>USE: eval
: eval-bi@- ( a b program -- n )
Line 261:
<lang factor>IN: scratchpad 9 4 [ dup * ] bi@- .
65</lang>
However, to be pedantic about it, we can adhere to the letter of the task. Note that althoughAlthough we are using a dynamic variable for x, it exists in a temporary, non-global namespace. As far as I can tell, <code>eval</code> is unaware of surrounding lexical scope.
<lang factor>SYMBOL: x
: eval-with-x ( a b program -- n )
1,808

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.