Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Well, my understanding of the above is that with sufficient trickery the data isnt really private. But I also agree that they are more or less equivelently private as compared to other things.

I agree - what I was trying to say that the C++ "private" variables are not really private either. We can always just treat the object as a sequence of bytes and get at them that way.

The way I see it the question "How do I do private object attributes" is not the same as "How to I avoid object attribute namespace clashes in inheritance". I would say that the first is just one answer to the second, the one that in many ways is the simplest to implement and may have certain interesting properties, but not the only nor necessarily the best answer by any means.

I agree they are not the only answer - but they are an answer. A nice simple answer in my opinion. I was providing one example of where private object attributes would be useful in perl - which was your request ;-)

With the exception of inside-out objects and closures the problem with other solutions, including package specific keys, is that they rely on the sub-class writer being aware of the mechanism for you to be completely safe. For me "more or less" and "probably won't" isn't good enough.

That probably says something very sad about my personality :-)

As you say, you can get around the problems with a bit of effort. However, the effort is enough that people get it wrong. I resent having to code stuff that the language should take care of for me. This stuff should be simple. Roll on perl6!


In reply to Re^4: characterstics of private in perl by adrianh
in thread characterstics of private in perl by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others scrutinizing the Monastery: (5)
    As of 2014-09-21 21:53 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (176 votes), past polls