Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Funny you put your example in the load namespace ;-). Or was that intentional?

I guess we agree to disagree. I find the syntax of

Very::Long::Module->load::as my $short => qw(foo bar baz);
very confusing. And a strange, roundabout way of setting $short.

...without trampling on any potential global namespace...

I think you touch on a very important flaw of my "as.pm" and of Package::Alias' approach as well. Consider a program which has:

use Foo; use Bar;
Now, Foo.pm has the following shortening (using my syntax for ease of reading):
package Foo; use Very::Long::Module::Name as Shorty;
and Bar.pm has the following shortening:
package Bar; use Some::Other::Long::Module::Name as Shorty;
Then you see we have a problem. One of the two modules will be referring to the wrong long module name, depending on whether an existing stash would be overwritten or not. In other words: you can only have one Shorty. That's because the stash aliasing (or the @ISA assignment) is not limited to the package scope from which it is invoked. And I don't see a way to encapsulate it, as all of the object creation is at run-time.

In my view, this pulls the rug from under any shortening approach currently available. As you cannot create code that can be well-behaved in that respect.

Too bad. It was a nice idea while it lasted... ;-)

Liz


In reply to Re: Re: Re: Re: use Very::Long::Module::Name as Foo; by liz
in thread use Very::Long::Module::Name as Foo; by liz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-19 22:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found