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!
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:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- 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
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||