Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Re^2: Private method variations

by stvn (Monsignor)
on Mar 01, 2004 at 17:33 UTC ( #332986=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Private method variations
in thread Private method variations

Maybe I am being niave but, is there something wrong with MyClass::PRIVATE:: ? It would be the least ambiguous of all IMO. I mean it would be hard to grab the PRIVATE:: root namespace, but if you are using a source filter anyway, you could generate the MyClass::PRIVATE:: "inner"-package with ease.

-stvn


Comment on Re: Re^2: Private method variations
Re^4: Private method variations
by adrianh (Chancellor) on Mar 01, 2004 at 21:38 UTC
    Maybe I am being niave but, is there something wrong with MyClass::PRIVATE

    Nothing beyond the extra 4 (for OUR::) or 5 (for MY::) characters that you have to type every time you call the method :-)

    I fear I am too lazy to want to type those extra characters that often.

    It also differs a little from the meaning of "private" in some other languages since you can easily get at the method from other classes if you ask for it explicitly - it's just in another package after all.

      It also differs a little from the meaning of "private" in some other languages since you can easily get at the method from other classes if you ask for it explicitly - it's just in another package after all.

      Quite true, but do you not intend it to be viewed as "private" ala Java/C++ etc? In which case, the name may actually help to "enforce" your intentions even though the reality is actually different.

      -stvn
        Quite true, but do you not intend it to be viewed as "private" ala Java/C++ etc? In which case, the name may actually help to "enforce" your intentions even though the reality is actually different.

        No I don't really want it to be viewed as the same as "private" in Java, C++ or whatever. I want it to be viewed as a solution to the sort of problem that is solved by "private" in those languages :-)

        Since most Perl coders are used to using my and our to solve namespace issues with variables I think those would be more familiar terms.

        The "private" concept in C++ conflates two separate issues:

        • Preventing access to a method
        • Describing the public interface of a class

        I like being able to tease those different functions apart - it can sometimes be useful. For example I've seen C++ coders jump through some evil hoops to test their private methods (e.g. #define private public when compiling in the test framework - ewww! :-)

        That said, the length is the main issue for me with using PRIVATE::. It's just too much typing.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2014-12-25 14:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (160 votes), past polls