On 6/24/09 Wed  Jun 24, 2009  10:45 AM, "Roman Makurin" <dro...@gmail.com>
scribbled:

> Hi
> 
> I need create a friend class. Is there any special that I
> need to know ? For now, I get object and work with it like
> with ordinary reference with direct access to internal
> fields.

All Perl classes are friends, if they use the most common method of object
instantiation, which is a blessed hash reference. If you use that method,
then any class may access the instance data of any class object, regardless
of the class to which the objects belong. Perl is a very friendly language.

As Larry says: "Perl doesn't have an infatuation with enforced privacy. It
would prefer that you stayed out of its living room because you weren't
invited, not because it has a shotgun".

Programmers can hide internal instance data, but it does take some work. You
can put data in package-scoped lexical variables, for instance.

Sometimes programmers will indicate private methods with a naming
conventions, such as a single underscore beginning a method name. But those
are only conventions, and the language does not enforce the restricted
access.




-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to