On 2010-07-31 20:23, Carl Mäsak wrote:
* Today we discovered that it's possible to break encapsulation by
detaching a method from an object of one class, and calling that
method on an object of another class. Which means that breaking the
encapsulation of a foreign class is as easy as creating a custom class
with all of the same private attributes, and with a method to print
(or otherwise reveal) them.

* It is my feeling that such encapsulation-breakage shouldn't be
allowed. Do you agree, p6l?
I don't really agree. The way OOP is implemented in perl 5 allows breaking encapsulation on many different levels, but I believe this has turned out to be a strength, since it allows you to use in those (very rare?) cases where it is needed.

When I found that all objects in perl 6 had fields, I was kind of put off, since it looked to Java-ish. What saves the spirit of perl is that people are still free to hack away (and then there are such roles as postcircumflex that reintroduces the very terse syntax, perl 5 is known for, avoiding the dot-hell of Java).

I believe we have a much larger task at hand, which is to write documentation that educates newcomers to use the right tools for the right job. I'd never recommend monkeypatching to a rookie programmer (or those silly .* and .+ "method" invocators) and I believe we owe people outside the perl community to explain the /intent/ behind the different constructs.

Regards,

Michael.

Reply via email to