develooper Front page | perl.perl6.internals | Postings from April 2008

get_namespace Oddity

Thread Next
From:
chromatic
Date:
April 6, 2008 00:10
Subject:
get_namespace Oddity
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?)

-- c

Thread Next


Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About