Yes, I knew I could, I just wanted to know if the object was unnecessarily
copied when accessing the subdictionary.
So, it's really an object reference, and not the actual object that is
stored? Hmm, that's good. Come to think of it, it's the only logical way,
but with RB you never know.
What I'm using it for? For exposing the class through the RBScript context.
So, users can do:
dim d As WhatevernameIgaveIt, and use the dictionary (by means of the
methods and properties I also exposed, of course). The reference to this
EDictionary is then stored in the main Context_Objects ElfDataDictionary.
Personally, the only class I'm using myself this way (in my templates, I
mean) is the FastString class, but perhaps someone might like or need to use
any of the other classes too (like Date, Dictionary, ...).
Your suggestion of using prefixes however is worth exploring as a possible
solution too, but only if it is faster. If needing to avoid object creation
is the only incentive then it's not worth it. There are not that many
objects, plus they're only created once during the entire RBScript run.
Ronald Vogelaar
--
http://www.rovosoft.com
----- Original Message -----
From: "Theodore H. Smith" <delete@...>
To: <elfdata@yahoogroups.com>
Sent: Friday, September 01, 2006 10:24 AM
Subject: Re: [elfdata] ElfDataDictionary inside an ElfDataDictionary
>
> On 1 Sep 2006, at 07:39, Ronald Vogelaar wrote:
>
>>
>> Hi Theo,
>>
>> I was just wondering, If I store an ElfDataDictionary in another
>> ElfDataDictionary, like so:
>>
>> Dim ed As ElfData
>> Dim d, e As ElfDataDictionary
>> d=New ElfDataDictionary
>> e=New ElfDataDictionary
>>
>>
>> ed="somekey"
>>
>> e.Value(ed)=d
>>
>>
>> ...if I were then to access ElfDataDictionary d (within e), do I
>> have access to it directly, or is a copy created every time I
>> access it?
>>
>>
>> Dim i As Integer
>> i=ElfDataDictionary(e.Value(ed)).Count
>
> Of course you can :) Everything is stored as an object reference just
> like any other object variable in RB.
>
> Just curious what are you using this for?
>
> Another idea could be to use prefixes. So instead of storing
> something in a subdictionary, store it with a prefix. Maybe: e.Value
> ("d.somekey") = Something
>
> Could save creating extra objects.
>