in reply to Re: Hiding methods of class
in thread Hiding methods of class

There is no technical way to prohibit someone from using a private method. You can write lots of code to try to restrict access but they can undo whatever you have written!
As cdarke posted, and I also mentioned in the Howto keep private methods private? thread, you can restrict access very efficiently, at compile time, to any lexical variable (including function refs, which can also be used as methods) by putting the variable in a limited scope. This should prevent anyone who isn't using XS internals hacking (like PadWalker) from getting at the method.

This strategy also has the advantage that it doesn't take up names in the inheritance tree, so you won't accidentally block out (or be blocked out) by sub or super classes. On the other hand that means you can't use it to create "protected" methods. But protected methods are the spawn of Satan, so you shouldn't care about that.

Replies are listed 'Best First'.
Re^3: Hiding methods of class
by Herkum (Parson) on Jan 17, 2008 at 04:37 UTC

    If the code is on someone else's box, they can change anything and everything you have written. If they can do that then there is no way you can have a guaranteed private methods. That was my point.