Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

schwern (1528)

schwern
  (email not shown publicly)
http://schwern.net/
AOL IM: MichaelSchwern (Add Buddy, Send Message)
Jabber: schwern@gmail.com

Schwern can destroy CPAN at his whim.

Journal of schwern (1528)

Thursday September 29, 2005
12:38 PM

Die die die UNIVERSAL::require!

[ #26939 ]

As I go back through my old modules, sometimes I wonder why I made certain choices. Today its UNIVERSAL::require which is used a whole lot more than I thought.

0.02 Mon Jun 25 15:00:19 EDT 2001
    * -->API CHANGE!<-- require() no longer dies on failure

Why did I decide to do that? I didn't record anything in the logs about it. I can't remember why I'd think $class->require shouldn't die seeing as how "require $class" does. And it introduced the clunky $UNIVERSAL::require::VERSION error global.

Bleh. Trying to decide if its worth the backwards incompat pain to change it.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • of dists using it:

    http://cpants.perl.org/dist/UNIVERSAL-exports [perl.org]

    Seems quite similar to what gonzui says...

    • Curses! I really wish I could just break compat because dying really is the better thing to do. Maybe I'll throw in a "use UNIVERSAL::require qw(die)" or something.
  • that you hadn't put it in UNIVERSAL::, but that's an entirely different issue.
    • If it wasn't in UNIVERSAL the module wouldn't work. The require method has to exist and be in a class' inheritence hierarchy *before* the class to be required is loaded.

      And this really is the sort of thing which should be universal.
      • It only has to be in UNIVERSAL because of the particular API you chose. It would be just as useful as something like this:

        Module::Loader->load($module_name);

        What bugs me about the current approach is that when I use a CPAN module that loads this, it magically adds require() methods to all of my classes, whether I want them or not.

        • It only has to be in UNIVERSAL because of the particular API you chose.

          Yep, but I can't exactly back out of that now. Remember, UNIVERSAL::require is an implementation of a Perl 6 RFC. People started using it. Go figure.

          What bugs me about the current approach is that when I use a CPAN module that loads this, it magically adds require() methods to all of my classes, whether I want them or not.

          require() is a special case. You're highly unlikely to create a method called "require" as its already a keyw

  • I'd love for you to fix it, or at least make it easier to get the right behavior. Otherwise, I end up writing the code that should be in there, myself.
    --
    rjbs