chromatic wrote:
Based on my reading of the documentation for get_namespace, this behavior isn't surprising, but based on what I want to do with the code, this behavior is very surprising:
works.pir:

        .sub 'main' :main
                .include 'runtime/parrot/include/test_more.pir'
        .end

breaks.pir:

        .namespace [ 'Any'; 'Namespace'; 'Will'; 'Do' ]

        .sub 'main' :main
                .include 'runtime/parrot/include/test_more.pir'
        .end

The problem is that the test_more.pir snippet contains:

        .local pmc exports, curr_namespace, test_namespace
        curr_namespace = get_namespace
        test_namespace = get_namespace [ 'Test'; 'More' ]

The final get_namespace call tries to find a namespace with that key *relative 
to the current namespace*.  That is, in the second example:

        [ 'Any'; 'Namespace'; 'Will'; 'Do'; 'Test'; 'More' ]

... which isn't exactly what I want.

What's wrong, my expectation or the documentation/implementation?  (If my 
expectation is wrong, what's the point of get_namespace when it breaks with 
spooky action at a distance depending on if you just so happen to be in another 
namespace with it?)
The behavior looks sane to me. .include is, quite literally, textual inclusion, nothing more. The get_namespace instruction is always relative. The code should probably be using an absolute namespace op, such as get_hll_namespace (or get_root_namespace), which looks up from the appropriate root. I understood get_namespace as doing a relative lookup within the current namespace.
Jonathan

Reply via email to