[IronPython] replacing engine.evaluate by CreateLambda
dinov at exchange.microsoft.com
Tue Sep 25 09:04:58 PDT 2007
Unfortunately there isn't a great way to do this. If EngineModule.GetGlobalScope were public you could create your own EM that's bound to locals (Or if engine.GetModuleScope were public).
That would let you use CreateLambdaUnscoped. It returns a ModuleBinder<TDelegate> and the ModuleBinder returns the delegate of the type you want. That lets you do:
ModuleBinder<Expression> binder = Engine.CreateLambdaUnscoped<Expression>(expression);
but because you can't bind an EM to a new set of locals you're stuck. You could call those through reflection or re-build IronPython and make them public.
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dody Gunawinata
Sent: Tuesday, September 25, 2007 12:05 AM
To: Discussion of IronPython
Subject: Re: [IronPython] replacing engine.evaluate by CreateLambda
Why not use CreateMethod instead of CreateLambda?
On 9/25/07, Christian Schmidt <Christian2.Schmidt at gmx.de <mailto:Christian2.Schmidt at gmx.de> > wrote:
How can I replace the 3 parameter Evaluate-function from PythonEngine
engine.Evaluate(expression, module, locals)
where expression is a string, module is a EngineModule and locals is a
IDictionary<string, object> by something like
delegate object Expression(IDictionary<string, object> locals)
Expression expr = engine.CreateLambda<Expression>(expression);
I've asked the same question a few days before, but didn't get an answer
so far. Is it not possible at all?
Thanks for any help.
Users mailing list
Users at lists.ironpython.com<mailto:Users at lists.ironpython.com>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Users