http://qs1969.pair.com?node_id=355035


in reply to Re: Re: Functional Inside Out Closure Objects
in thread Functional Inside Out Closure Objects

To start with, perl's object system was a bolt-on to the existsing module system, which is both ugly (because it kind of exposes the soft underbelly of objects) and cool at the same time (you can do some crazy stuff with modules/typeglobs, and you can now do them with objects too :)

How it handles inheritance is another.

package Foo; @ISA = qw(Bar);
This takes the idea of inheritance and converts it into a "magic" laden assignment statement. This exposes too much of the details of how perl manages inheritance, which IMO is ugly. Maybe I am a purist, but I think that declaring inheritance should be part of the class declaration, or at the very least have its own keyword.

Constructors in perl are nothing special, which at first glance is cool, but it does lead to some ugly code when calling base class constructors in subclasses. I personally like the C# syntax for these things:

class Bar { string name; public Bar (string name) { this.name = name; } } class Foo : Bar { Hashtable attributes; public Foo (string name, Hashtable attributes) : base(name) { this.attributes = attributes; } }
Also, the idea that an object is just a blessed reference IMO is another double edged sword. It makes encapsulation a big issue/problem. (Sure I know you can do Inside-Out objects and closures, etc etc etc, but all of them just add to the already touchy syntax.) Now I know the idea is that you shouldn't mess with the internals because you were not invited, and that it then becomes a social problem. But I would rather not have the social problem at all and have strong encapsulation.

All this said, I love perl, so I have worked with/around all this stuff in my own way, but it doesn't change the underlying ugliness of it. And yes, some might call this elegance, and I will be the first to admit that there is a fair amount of elegance in how minimally invasive the adding of objects to perl was, but when you get deep into the thick of it, there is some real ugliness there no matter what.

-stvn