develooper Front page | perl.perl6.language.objects | Postings from September 2000

Re: Draft RFC: new pragma: C<use namespace>

Thread Previous
From:
Hildo Biersma
Date:
September 13, 2000 09:06
Subject:
Re: Draft RFC: new pragma: C<use namespace>
Message ID:
39BFA5CD.2D813C4D@msdw.com
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

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About