Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Modules: computing a constant, "on load" or in new()?

by BrowserUk (Pope)
on Aug 20, 2013 at 21:16 UTC ( #1050247=note: print w/ replies, xml ) Need Help??


in reply to Modules: computing a constant, "on load" or in new()?

Putting them in new means doing the same work over. That's a waste of cpu and a violation of DRY principle.

There is nothing 'dirty' about setting up the 'constant' requirements of your module at load time.

Indeed, that exactly what you are doing when you declare your functions.

sub XYZ { ...} is exactly the same as *{__PACKAGE__'::XYZ'} = sub { ... };; it is a load-time assignment to a symbol in your package stash.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.


Comment on Re: Modules: computing a constant, "on load" or in new()?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2014-07-26 01:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (175 votes), past polls