Login  Register

Supply named temporaries to Compiler>>#evaluate:...

Posted by Sean P. DeNigris on Feb 04, 2015; 5:48pm
URL: https://forum.world.st/Supply-named-temporaries-to-Compiler-evaluate-tp4803689.html

I want to be able to evaluate a string like '2 + arg1' and supply anObject for arg1 to the compiler.

I naively tried:
| aContext |
aContext := thisContext copy
        tempNamed: 'arg1' put: 1;
        yourself.
Compiler evaluate: '2 + arg1' in: aContext to: nil

which didn't even come close to working!

Any pointers?
Cheers,
Sean