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.
For ex, if you have a script snippet like - "someVar = 1+2" the variable access for 'someVar' will result in a call to TryGetExtraValue. But if you can return a false, the value will be fetched from the scope and it will correctly lookup the value as '3'. So, instead of calling the TryGet* method when the scope cannot find the symbolID, it calls this method for all symbolIDs and whenever the TryGet* returns a false, it looks the value up in its own storage. Hope this helps. Sesh -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Christian Schmidt Sent: Thursday, August 21, 2008 8:36 AM To: Discussion of IronPython Subject: [IronPython] CustomSymbolDictionary and conversions Hi, I've derived from CustomSymbolDictionary to add specific variables to a scope (see seshadripv's blog). What I would expect from a method called TryGetExtraValue is that only if the scope (where the IAttributesCollection was added in the constructor) cannot find the SymbolId, the ExtraValue-method is called. But it seems that this method is called on each request. Therefore one needs to have a base scope, which is given to the SymbolDictionary and evaluations take place in an additional scope created with the IAttributesCollection in the constructor. protected override bool TryGetExtraValue(SymbolId key, out object value) { if (baseScope.TryGetVariable(SymbolTable.IdToString(key), out value)) return true; // ... } As the baseScope only has TryGetVariable(string), I need to convert the SymbolId to a string and baseScope probably converts the string back again to SymbolId. Is there a way to work more directly with the IAttributesCollection? Thanks, 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
