RosettaCodeData/Task/Runtime-evaluation-In-an-environment/Zkl/runtime-evaluation-in-an-environment-1.zkl
2023-07-01 13:44:08 -04:00

8 lines
320 B
Text

fcn evalWithX(text,x) {
f:=Compiler.Compiler.compileText(text);
f.x = x; // set free var in compiled blob
f.__constructor(); // run blob
vm.regX // compiler sets the VMs X register for cases like this
}
const TEXT="var x; x*2"; // variables need to be declared
evalWithX(TEXT,5) - evalWithX(TEXT,3) #--> 4