in reply to Module Naming Dilemma

I also think that using the pragma 'class' for this purpose is a very bad idea.

Partly because it implies the aliasing would only work for classes, when it would work for any package.

Partly because a 'class' pragma could be used for so many other, more specific purposes.

Maybe package?

use package Long::Unweildy::Module::or::Package, as => 'LUMP';

Or minym. As a non-word it is unlikely to clash with any other usage, but the derivation should be quickly and easily grasped by anyone encountering it for the first time.

use minym 'LUMP', for => 'Long::Unweildy::Module::or::Package';

You might even become responsible for giving the language a new word :)


Examine what is said, not who speaks.
Silence betokens consent.
Love the truth but pardon error.

Replies are listed 'Best First'.
Re^2: Module Naming Dilemma
by Ovid (Cardinal) on Jan 05, 2005 at 03:07 UTC

    package is a reserved word, so I won't use that. Second, this module only works for classes. It doesn't work for non-OO stuff. The reason is pretty straight-forward. To make it work for a procedural module, the syntax would be like this (picking "aliasing.pm" as a nice alternative):

    use aliasing "Really::Long::Package::Name"; print Name::some_func();

    In order to get that to work, I need to alias typeglobs together like namespace does. However, by literally pulling things from one namespace to another, I would break a lot of code that is expecting a particular namespace (whether or not it should is an argument for someone else.) Thus, the principle of least surprise tells me that I need this to work only for classes and I do this by simply providing a subroutine that returns the original class name.

    Further, from my experience with code that's very similar to this, packages with long names are either procedural code that exports what I need (hence I don't usually use the package name after the first usage) or classes for which the aliasing code makes sense. I don't typically find cases where I need to do this:

    my $foo = Really::Long::Package::Name::some_func();

    Of course, your mileage may vary.

    Cheers,
    Ovid

    New address of my CGI Course.

Re^2: Module Naming Dilemma
by bmann (Priest) on Jan 05, 2005 at 02:33 UTC
    ...the derivation [of minym] should be quickly and easily grasped by anyone encountering it for the first time.

    Everyone except me, I guess... Care to enlighten me?

      1. pseudonym: false name.
      2. synonym: same (or similar) word (name).
      3. antonym: opposite word (name).
      4. anonym: anonymous name.
      5. minify: To make smaller or less significant; reduce.
      6. minym: minimal name? :)

      Examine what is said, not who speaks.
      Silence betokens consent.
      Love the truth but pardon error.
        I think I would have gotten that if it were 'mininym' rather than 'minym'.
        Interesting, BrowserUK. I was looking for an acronym, something like "Module Import Namespace..." and got lost.

        Hey - how about "Maybe I'm Not Your Mother" ;)