On 13 Sep 2000, Piers Cawley wrote:
> Hildo Biersma <[EMAIL PROTECTED]> writes:
>
> > Piers Cawley wrote:
> > 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
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