As I understand PDD-21, there is a single parrot namespace tree. This
tree incorporates the HLL names at the top-most branches, so that
namespaces created in different HLLs will be different namespaces.
(PDD 21:
http://docs.parrot.org/parrot/latest/html/docs/pdds/pdd21_namespaces.pod.html)
Thus, tcl, perl5 and perl6 will live in
/tcl
/perl5
/perl6
respectively.
Further, the various ..._hll_... opcodes know about and support this, so
that doing a C<get_hll_global [ 'Root', 'Branch', 'Leaf' ], foo> in
perl5 will resolve to /perl5/Root/Branch/Leaf.
Further, using the ..._root_... opcodes will support this:
C<get_root_global [ 'perl5', 'Root', 'Branch', 'Leaf' ], foo> resolves
to the same as the above.
Further, each namespace has a namespace PMC that connects information
about the namespace to other parts of the system, including supporting
an C<export_to> method for exporting symbols.
Further, PDD-21 specifies that HLLs must store implementation internals
in an HLL root namespace named with a leading underscore, so that tcl,
perl5, perl6 store their bits in
/_tcl
/_perl5
/_perl6
Thus, a tcl compiler support function called str2num would live in
/_tcl/str2num
or possibly some lower level, and any call generated to the str2num
function would look like:
..HLL 'tcl'
..namespace []
..sub main :main
$S0 = '0'
$P0 = get_root_global [ '_tcl' ], 'str2num'
$I0 = $P0($S0)
.return ($I0)
..end
I have no idea whether or not there is a connection between the
generated bytecode and the HLL/compiler, other than setting up some
strings that are part of the namespace tree.
At this point, I need to ask "Is this right?" That is, have I got all
this stuff right so far, or is there some error in my understanding?
If this is right, then how do I write the support code. What HLL do I
declare, and what can I expect in the way of opcode support?
If I write my support code as
..HLL 'tcl'
..namespace []
then the ..._hll_... opcodes will think they are in the "user"
namespace, which may or may not be cool. But at least any connections
from the generated bytecode to my HLL will be preserved correctly.
If I write my support code as
..HLL '_tcl'
..namespace []
then the ..._hll_... opcodes, and the simple function call interface,
will handle calls to other innards correctly, which seems like the "most
right thing", but any reference (if one exists) between the bytecode and
the compiler/HLL is no longer accurate. (Since '_tcl' ne 'tcl')
So what's the right way to express this?
Also, is there (should there be) a standard for compilers, too? I
imagine that all the various perl6 compilers are going to emit their
code in the 'perl6' hll, and have their innards over in the '_perl6'
space. Shouldn't they be putting things in /_perl6/rakudo or whatever?
=Austin
_______________________________________________
http://lists.parrot.org/mailman/listinfo/parrot-dev