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


in reply to Procedural vs OOP modules

I've come to the conclusion that what most people want when they think of OOP is Perl are is this "oop" interface that uses uses the $myobj = FOO->new; idiom + accessors to fields. E.g., the more I use Util::H2O, the more this is also clear to me - at least in what I want.

My recommendation is to go with the "oop" interface but only for the instantiation of the "object" and for providing accessors for the fields. I'll also add, that when I see use a module that doesn't provide this, it feels a little yucky. Beyond that, Perl "OOP" fur real is the domain of an extremely vocal but tiny minority. It is very true that going beyond the means for instantiating the "object" and providing accessors necessarily yields code that looks - and behaves - like a completely different language. Again, going back to my experience with Util::H2O I've been able to summarize my desire for "improving" OOP support in Perl to go no further than a better bless that provides the kinds of things h2o provides, but can still be used in the same way - h2o comes close to achieving this but to get the last bits of what I want requires non-idiomatic tricks.

Namely, a) using h2o to define a "class" and b) taking an already blessed reference and adding accessors to it as easily as it does for non-blessed hash references. What I really want is to be able to have a bless that can magically add accessors like h2o, but that can also be used to do surgery on already blessed references - and also remain the basis for which "OOP" modules get OOP'd.