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

[email protected] (Dave Storrs) Wed, 13 Sep 2000 11:15:58 -0700 (PDT)
Newsgroups perl.perl6.language.objects
Message-ID <Pine.BSF.4.10.10009131114260.23329-100000@megazone23.bigpanda.com>
Scuse me...I just realized that I missed an edit in my previous post.  The
[1] that you see was intended to be a footnote talking about the
possibility of conflicting namespace aliases.  When I expanded that into
the final couple paragraphs, I forgot to take out the [1].  Sorry for the
confusion.

			Dave

 On Wed, 13 Sep 2000, Dave Storrs wrote:

> 	How about if we added a list, @NAMES, into which you could assign
> namespace shortcuts, something like this:
> 
> package main;
> 
>         push @NAMES, ("A::B::C" => 'ABC', 
>                       "X::Y::Z" => 'XYZ',
>                       "StupidlyLongMathThingie" => "SLMT",
>                       "Bar::Baz" => ""
>                      );
> 
> 	ABC::do_stuff();               # prints "ABC";
> 	XYZ::do_stuff();               # prints "XYZ"; 
> 	SLMT::do_stuff();              # prints "4";
> 	# do_stuff();	               # [1]
> 
> 
> 	sub do_stuff() { print "main"; }
> 
> package A::B::C;
> 	sub do_stuff() { print "ABC"; }
> 
> package X::Y::Z;
> 	sub do_stuff() { print "XYZ"; }
> 
> package StupidlyLongMathThingie;
> 	sub do_stuff() { print 2 + 2; }
> 
> package Bar::Baz;
> 	sub do_stuff() { print "barbaz"; }
> __END__
> 
> 	Whenever the interpreter saw a namespace usage, it would need to
> check @NAMES in addition to checking the included modules list.  
> 
> 	The problem comes when the user aliases two different namespaces
> to the same alias (e.g., "Foobar" => "F", "Foxtrot" => "F")
> 
> 	In this case, if the usage is unambiguous (e.g., F::do_foxtrot(),
> and the Foobar module does not contain a sub by that name), then perl
> should raise a warning but go ahead and execute.  If the usage is
> ambiguous, this should be a fatal error.
> 
> 
> 				Dave
> 
>