[Canberra-pm] Q: Subclassing an object with closures

Daniel Pittman daniel at rimspace.net
Mon Nov 15 18:32:37 PST 2010


Alex Satrapa <grail at goldweb.com.au> writes:
> On 16/11/2010, at 12:54 , Daniel Pittman wrote:
>> Alex Satrapa <grail at goldweb.com.au> writes:
>> 
>>> I think I'm going to have to hand in my Perl license, I've encountered a
>>> structure I don't understand and now I have no idea how to extend the
>>> class.
>> 
>> The goal of a bunch of that code is to make it "private", so that you can't
>> fiddle with it, so it isn't a great shock that extending it is hard.
>
> Why would someone do something so selfish in a module contributed to CPAN?

The same reason C++ and other languages have baked-in private/protected/public
protection for members: because there are design and style reasons you might
want to protect those.

Is it overall better?  Maybe.  Is it Perl style?  Not really; it trusts people
not to be stupid, generally, but some people don't agree. :)

(Theoretically those protections are used in a sensible way so that subclasses
 can easily extend behaviour.  In this case ... not so much.)

>> ...is the right solution to fix the module, then submit it to the author,
>> and just depend on the latest CPAN release?
>
> Well, in an ideal world* yes. In the real world, no. I will fix the module,
> rendering the "class variables and methods" as actually belonging to the
> namespace, and suggest to the author that he shouldn't be pulling silly
> stunts like this.
>
> For my immediate purposes, I'll simply override the methods as required in
> my subclass. I have a deadline to meet, since I write code for money rather
> than intellectual stimulation :)

Uh-huh.  That sounds like the right decision to me.

>
> Alex
>
> * The "ideal world" being defined as one where time and money are not a constraint on any activity.
>
> Alex Satrapa | web.mac.com/alexsatrapa | Ph: +61 4 0770 5332
>
>
> _______________________________________________
> Canberra-pm mailing list
> Canberra-pm at pm.org
> http://mail.pm.org/mailman/listinfo/canberra-pm

-- 
✣ Daniel Pittman            ✉ daniel at rimspace.net            ☎ +61 401 155 707
               ♽ made with 100 percent post-consumer electrons


More information about the Canberra-pm mailing list