Hi Christian,

Hope these answer your questions...

>When accessing the baseScope from your example, isn't
>SymbolTable.IdToString(key) for each access to the baseScope slow?
>I wonder, why there is no ScriptScope.GetVariable(SymbolId) method.

The number of scenarios where a user would invoke any Hosting API in terms of 
SymbolId is very low. So it's much simpler not to provide an overload that 
takes in a SymbolID. Also, the static methods in the 'SymbolTable' class lets 
conversion to and from SymbolID quite simple and straightforward.


>What would be the approach to extend a ScriptScope by the properties of
>an object? Or in other words: How can I evaluate an expression in an
>object's scope?

Any valid IronPython script snippet can be executed in the context of a scope. 
Since an expression is just another code snippet,you can the appropriate 
hosting API methods to achieve it. There are more than one ways to do it, the 
most typical being the one where you'd create a 'ScriptSource' object using the 
ScriptEngine.CreateScriptSource* methods and invoke the 'Execute' method on it 
and passing the relevant scope to it. (More information about various ways to 
execute a code snippet can be found at 
http://blogs.msdn.com/seshadripv/archive/2008/07/28/various-ways-to-execute-script-using-the-dlr-hosting-api.aspx)

Here's a typical execute call that executes a expression in a given scope.
                ScriptScope scope = pythonEngine.CreateScope();
            var src = eng.CreateScriptSourceFromString( 
"someVar1+someVar2",SourceCodeKind.Expression);
            src.Execute(scope);

thanks
sesh

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Christian Schmidt
Sent: Thursday, August 21, 2008 3:48 PM
To: Discussion of IronPython
Subject: Re: [IronPython] CustomSymbolDictionary and conversions

Hi Seshadri,

thanks for your answer.

> The TryGetExtraValue and TrySetExtraValue methods can return a false
> for SymbolIDs that they don't maintain. Those values will be looked
> up in the actual scope.

I see, makes sense.

When accessing the baseScope from your example, isn't
SymbolTable.IdToString(key) for each access to the baseScope slow?
I wonder, why there is no ScriptScope.GetVariable(SymbolId) method.

What would be the approach to extend a ScriptScope by the properties of
an object? Or in other words: How can I evaluate an expression in an
object's scope?

Regards,
Christian
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to