Perl doesn't support a friend relationship between objects, nor does it support private or protected methods. What is usually done for private methods is to prefix the name with an underscore. I occasionally have methods that I think of as friend methods. Meaning that I expect them to be used by a specific object, or an object with a specific responsibility, but I'm not sure if I should make that method public (meaning foo ) or private ( _foo ) or if there's a better convention? is there a convention for friend methods?
|
|
|||
|
|
|
I'm not aware of any conventions or best practices for friend methods that the Perl community uses. If you felt the need to designate a prefix for these methods I don't see any real issue with it, but I don't see any advantage in it either. Personally I'd just make it a "public" method, without the underscore, and without any additional prefix. |
|||
|
|
|
If you really want to have Friend semantics you could do something like this:
I named the method with an underscore so that Test::Pod will will not complain that it is not documented. |
|||
|
|
|
Perl does not, by itself, enforce private methods or attributes, no. In fact, Larry Wall was once quoted as saying:
If you're using If you want true privacy, though, it looks as though |
||||
|