http://qs321.pair.com?node_id=561638


in reply to Perl Privvies

I don't recall this caller-based technique to enforce privacy as being used much,

My personal opinion is that most people don't feel they "need" it. This is back to the question of "culture" vs "control". In my inside-out objects talk, I use the analogy of double-yellow lines on the road versus concrete lane barriers. (Apologies to non-US drivers -- I hope the analogy is still clear.)

My point is that Perl isn't really about the second way of doing things. And I suspect that many (most?) Perl programmers are sufficiently happy with the first that at most a simple caller() check is all they deem worthwhile. Anyone who really wants around it is going to find a way and there are diminishing (or even negative) returns in the time required to even try to stop them.

Just for fun, if you really want to bend your brain in the "subterfuge race", don't forget about overriding CORE::GLOBAL::caller() or the "# line 43 Bar.pm" trick. (See the very end of perlsyn for the last one.) Even for "private" lexical subs, I bet one could get at them with PadWalker.

-xdg

Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Replies are listed 'Best First'.
Re^2: Perl Privvies
by Mutant (Priest) on Jul 17, 2006 at 08:20 UTC
    Really like that analogy.. explains it very clearly (which can often be difficult, especially when describing the situation to people who come from a Java (etc.) background).

      Thank you. I spent a while trying to come up with an analogy that didn't involve shotguns and living rooms or whatever is the commonly-cited analogy for encapsulation. That one never really made a lot of sense to me.

      -xdg

      Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Re^2: Perl Privvies
by rinceWind (Monsignor) on Jul 17, 2006 at 14:21 UTC

    In the UK, as indeed in other European countries, double yellow lines are for parking restrictions, close to the gutter, by the pavement/sidewalk. Double white lines are the equivalent "do not cross" of your double yellows. We tend to use the term "crash barrier" for anything that generically stops you from driving over the central reservation.

    Good analogy though. Like it!

    --

    Oh Lord, won’t you burn me a Knoppix CD ?
    My friends all rate Windows, I must disagree.
    Your powers of persuasion will set them all free,
    So oh Lord, won’t you burn me a Knoppix CD ?
    (Missquoting Janis Joplin)

      Over here in Norway, we have double-yellows. That is to say, when there even are two lanes. Even on the main arteries through the fjord region, there are long stretches of single-lane twisties. I have great respect for the lorry drivers around here!
A reply falls below the community's threshold of quality. You may see it by logging in.