Runtime evaluation/In an environment: Difference between revisions

Content added Content deleted
m (→‎{{header|PHP}}: php var inside functions, if not declared global, are local; should the code be "splitted" as done for tcl? waiting feedback)
(→‎{{header|Metafont}}: if the problem was the "global" variable... fixed (as tcl, similar to php))
Line 84: Line 84:
=={{header|Metafont}}==
=={{header|Metafont}}==


<lang metafont>vardef evalit(expr s, v) =
{{incorrect|Metafont|Either do not use a global variable, or note that this is impossible.}}
save x; x := v; scantokens s
enddef;


a := evalit("2x+1", 5);
<lang metafont>string p;
p := "2x + 1";
b := evalit("2x+1", 2);
show (a-b);
x := 5;
end</lang>
a := scantokens p;
message decimal a; % 11
x := 2;
b := scantokens p;
message decimal b; % 5</lang>


=={{header|Octave}}==
=={{header|Octave}}==