UNIVERSAL::require lives!

schwern on 2005-10-04T00:00:25

Flip-flop. Flippity-flop goes my braine.

I've decided not to change the behavior of UNIVERSAL::require. Why?

1) Jesse's suggestion of using $@ instead of $UNIVERSAL::require::ERROR. It makes the error checking code much less disgusting to type.

2) The existing behavior has survived four years without anyone hating it enough to file a bug or patch.

3) Its such a simple module its not worth the turmoil.


I thought that would work anyway...

Simon on 2005-10-04T09:03:17

I always used "$foo->require or die $@". Now it'll actually be the right thing! See, pick the interface that your users would use naturally...

Could you still have an option to make it die?

nothingmuch on 2005-10-04T10:18:24

Like add a require_or_die method?

Re:Could you still have an option to make it die?

schwern on 2005-10-08T08:45:06

I've thought about that. It seems silly given my reasons for wanting to make it die.

1) People would write $module->require without realizing it wouldn't die on error.

Well, require_or_die() doesn't help with that. If they don't think $module->require doesn't die they'll probably never notice require_or_die().

2) $module->require or die $UNIVERSAL::require::ERROR is nasty.

$module->require or die $@ is nearly as short as $module->require_or_die

So not really worth it.

Re:Could you still have an option to make it die?

tyan on 2005-10-13T11:03:17

How about an option when you use the module:

use UNIVERSAL::require qw/fatal/;

SomeModule->require; # blows up

?

Re:Could you still have an option to make it die?

schwern on 2005-10-14T23:14:31

Already covered why that won't work.