Re: Draft RFC: new pragma: C<use namespace>
[email protected] (Hildo Biersma) Wed, 13 Sep 2000 17:05:33 +0100
| Newsgroups | perl.perl6.language.objects |
|---|---|
| Organization | Morgan Stanley Dean Witter & Co. |
| Message-ID | <[email protected]> |
Piers Cawley wrote: > > > This is a bit dangerous, since we can get into ambiguities again. > > If I have A::B::C::Foo, A::B::C::Bar, X::Y::Z::Foo and X::Y::Z::Bar, > > I'd like to use shorthands for A::B::C's Foo and X::Y::Z's Bar at the > > same time. > > Well you can't. The patch that I pinched this RFC from is a lexically > scoped affair, so if you want to use a different namespace somewhere > else you are free to do so: > > use namespace 'A::B::C'; > my ::Foo = ::Foo->new; > use namespace 'X::Y::Z'; > my ::Foo = ::Foo->new > > should work. Yeah but - I am asking for more control. Could we not support both: using namespace 'A::B::C'; in which ::Foo refers to A::B::C::Foo, and no reference to X::Y::Z works and using A::B::C::Foo; using X::Y::Z::Bar; in which ::Foo is now an alias for A::B::C::Foo and ::Bar is an alias for X::Y::Z::Bar. This would end the effect of a previous 'using namespace' statement. I've written this with a 'using' keyword, we can of course also use the module syntax in your proposal... Hildo