I lost track of this a bit (sorry, work intruded) so lets pick it back up again.

As we last left it, I'd proposed we access namespaces via a multidimensional key to dodge the whole "What separator does *this* language use?" problem. I'd also proposed that we split the namespace and thing name into separate parameters.

Turning the namespace selector into a multidimensional key just seems to make sense. I'd originally hoped we could keep things unidimensional, in one really big hash, but that idea now seems charmingly naive, and if we're going to be multidimensional we might as well do it right. I don't see any reason to not just do this.

The reason for splitting the lookup into two parameters, namespace and name, instead of one combined parameter, is a bit less solid, so I'm up for arguments here. Consider, however, the case where we're accessing multiple named globals, a not uncommon thing. If we go with the single parameter case it looks like:

   load_global $P1, ['foo'; 'bar'; '$baz']
   load_global $P2, ['foo'; 'bar'; '$xyzzy']

but if we go with the split parameter case it looks like:

   load_global $P1, ['foo'; 'bar'] '$baz'
   load_global $P2, ['foo'; 'bar'] '$xyzzy'

The difference there being that, rather than having two separate constant keys we have one constant key and two string constants. This should result in less memory usage and a faster startup time for bytecode that accesses globals (which should pretty much be all of it).

It has the additional advantage of *not* needing to construct an extra key when doing symbolic access to symbol tables. Code like:

$$foo = 12;

where $foo has a string in it won't need to have a key constructed -- the bytecode would look like:

   load_global $P1, CURRENT_PACAKGE_CONSTANT, $foo
   $P1 = 12

assuming the string in $foo has no package qualifications. If it does a key needs to be created, of course, but it makes one of the access legs (the leg with no qualification) faster without impacting the speed of the less-common package-qualified leg.

Time for discussion, and this time I promise to keep up. :)
--
                                        Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to