develooper Front page | perl.perl5.porters | Postings from July 2011

Partially standardizing package naming

Thread Next
Father Chrysostomos
July 31, 2011 13:23
Partially standardizing package naming
Message ID:
As part of my &CORE::keyword work, I have a patch to make sure that the CORE package is always named CORE, not main::CORE or ::CORE. This allows the code that adds the subs to identify that package reliably, without innocent-looking code like &::CORE::foo sabotaging the entire package.

It’s consists of code like this in Perl_gv_fetchpvn_flags:
			if (GvSTASH(gv) == PL_defstash
			 && name_cursor-nambeg == 4
			 && strnEQ(nambeg, "CORE", 4))
			    hv_name_set(stash, "CORE", 4, 0);
				stash, nambeg, name_cursor-nambeg, 0
I’m wondering whether I should apply it to any stash directly inside PL_defstash. That will make the code simpler, and will also eliminate the interesting side-effect of referring to $::Encode::decode_utf8 before loading Encode (it causes the package to be named ::Encode). It will also stop my hack that breaks the ref eq '0' hack from working, but that’s OK. :-) This will only apply to stashes nested directly inside the main stash, as that’s the only case that’s getting in the way of something else.

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About