Re: Draft RFC: new pragma: C<use namespace>
[email protected] (Piers Cawley) 13 Sep 2000 15:35:02 +0100
| Newsgroups | perl.perl6.language.objects |
|---|---|
| Message-ID | <[email protected]> |
Hildo Biersma <[email protected]> writes: > Piers Cawley wrote: > > =head1 ABSTRACT > > > > C<my Big::Long::Prefix::Class $object = Big::Long::Prefix::Class-E<gt>new> > > is a pain in the bum to type. We should replace this with > > > > use namespace 'Big::Long::Prefix'; > > my ::Class $object = ::Class->new; > > 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. -- Piers