Okay, it's time to deal with a particularly unpleasant 
topic--cross-language namespace management.

This is *only* for those cases where we need to look things up by name in 
some namespace (either global or lexical), and doesn't affect what we do 
with the PMC we get back once we've done that. 

Basically, the problem is this: Perl, along with a number of other 
languages, allows multiple things with the same name, as long as they're 
different types. (You can have an array and a sub with the same name, for 
example) Generally languages split at least the sub/function namespace out 
from the variable namespace, though some languages (notably perl) also 
split the variable namespace by broad type.

Now, this wouldn't be a problem--we could segregate the namespaces, 
except... Introspecting facilities in those languages assume that there is 
a single unified namespace, rather than a type-split namespace, and 
there's some disagreement as to how many namespace types there should be.

Perl gets around this by either two-levelling the names (so that there's a 
single entry for 'foo', and that PMC-equivalent is an array that has a 
slot for scalar, hash, array, sub, and so forth), and while we can do 
that, well... yech. (And I mean that sincerely) The proposal for *user* 
views (i.e. we can screw with what they ask for before we look) in perl 6 
is to have separate entries in the namespace with an appropriate perl 
prefix, so if there's a $foo in your program, there's a "$foo" name in the 
name table.

That, as you might expect, has just a *few* cross-language issues. Many 
other languages don't draw the subtype distinction that perl does--you're 
allowed one variable 'foo' and that's it, regardless of its type. 

Personally I'm currently of the opinion that we should split the 
namespace into functions/methods/subs and variables, either by convention 
with a prefix character or with an explicit parameter, and let the 
variables fend for themselves. Whatever language prefix (if any) gets 
used, and if people go dancing through someone else's namespace they may 
find things they didn't expect, well.. "Here there be dragons. 
Marshmallows, anyone?" A leading NULL byte for subs seems quite nice if we 
keep them in the same table as variables, or we can split the table in 
two.

I'm currently pondering the namespace separator character as well. Perl 
uses :: between levels, and I've no idea off-hand what other languages 
use. Personally I'm tempted to use a null between levels and put in a 
translator layer in generated bytecode for symbolic access from HLLs.

                                        Dan

Reply via email to