Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re^5: stronger than eval?

by mreece (Friar)
on Sep 21, 2006 at 19:46 UTC ( #574254=note: print w/replies, xml ) Need Help??

in reply to Re^4: stronger than eval?
in thread stronger than eval?

if the method is called use or require, then yes, i am ok with that, even when it results in dying if you try $obj->use because you did not define your own use method on that class (which is what would typically happen anyway, except with a different error).

the more exceptional case would be when you expected to handle use or require methods via AUTOLOAD, but i would never expect such so adding these methods to UNIVERSAL is ok with me.

Replies are listed 'Best First'.
Re^6: stronger than eval?
by perrin (Chancellor) on Sep 21, 2006 at 20:19 UTC
    I have to agree with diotalevi on this: there is no good reason for this to be done through UNIVERSAL::. It's just a simple utility method. It does not need to be added to every namespace automatically.

      I agree too. For example,

      use UNIVERSAL::require (); Cache::File->use() or print "error: $@";

      could be written as

      use Module::Loader qw( load ); load Cache::File or print "error: $@";

      Just as readable. Just as simple. No polution of UNIVERSAL::. And with the right prototype, load's argument doesn't even need to be quoted.

      Update: The module I made up above already exists as Module::Load!
      Update: Module::Load dies instead of returning false.

Re^6: stronger than eval?
by diotalevi (Canon) on Sep 21, 2006 at 20:13 UTC

    Ok, fine, I guess. What's also missing is that there's no need to implement this with UNIVERSAL:: pollution. This could have just been a "smarter" use and require function named something appropriate and it wouldn't have caused issues for other objects. I have sympathy for features that are best (or perhaps only) implemented by polluting UNIVERSAL:: but this isn't one of them.

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://574254]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2021-02-27 19:11 GMT
Find Nodes?
    Voting Booth?

    No recent polls found