Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: Abandon "our" declarations (was: Re: our scope and packages) (export)

by rir (Vicar)
on Aug 29, 2008 at 18:14 UTC ( [id://707809]=note: print w/replies, xml ) Need Help??


in reply to Re: Abandon "our" declarations (was: Re: our scope and packages) (export)
in thread our scope and packages

It is hard to justify such code in any serious context.

This is written to be an object method but it effects the object's package namespace not the object.

This is code that should not be applied to mature code since the My::Config module needs be invaded and all the client code needs to be altered to use it. If there is already a My::Config::import function, it would be better to change the lexicals to package variables inside My::Config.

If writing new code, such misuse of lexicals is perverse. ... That is the thing I like about it. Ahh.

Be well,
rir

Replies are listed 'Best First'.
Re^3: Abandon "our" declarations (was: Re: our scope and packages) (export)
by tye (Sage) on Aug 30, 2008 at 06:21 UTC
    This is written to be an object method but it effects the object's package namespace not the object.

    Um, that statement leaves me unsure what code you were reading when you wrote that. :) What I wrote is closest to being a class method; it certainly isn't an object method. But the similarity it has to being any kind of method at all is only in that it follows the convention set forth in Perl 5 as to how 'use' works. It also doesn't "affect the object's package namespace" (there are no objects involved, so s/object's package namespace/package/); it impacts the namespace of the other package(s) that use this module.

    If there is already a My::Config­::import function, it would be better to change the lexicals to package variables inside My::Config.

    Huh? There was not already an My::Config::import(). There wasn't even a My::Config, there was just a file with no package declaration and an our %prod declaration.

    This is code that should not be applied to mature code since the My::Config module needs be invaded and all the client code needs to be altered to use it.

    If there had already been a My::Config::import(), then the interface would be exactly the same and no "client" code would need to be altered. Code that uses the theorized My::Config should not care at all how the hash you ask to be exported is implemented internally.

    If writing new code, such misuse of lexicals is perverse. ... That is the thing I like about it. Ahh.

    Well, that is a clear statement of opinion. But I wish I could understand the reasoning behind that opinion. (:

    - tye        

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (None)
    As of 2024-04-25 03:56 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found