http://qs321.pair.com?node_id=339178


in reply to •Re: It's a dog, but what kind? (polymorphism , in Perl OO)
in thread It's a dog, but what kind? (polymorphism , in Perl OO)

my $class=ref($proto)||­$proto;

I understand the reasons to avoid this construct.

But if you avoid it, then you need to replace it with something. Unfortunately, although I often see this construct derided, I very seldom see suggestions for what to replace that line with (even when I come out and ask for it). The most straightforward replacement is unacceptable to me. See Re^2: A few Perl OOP questions. (disparaging) for why.

I also consider the objections to this to be rather minor in impact in a lot of practical situations and appreciate the "sloppy" advantages of $obj->new() in a lot of pracitcal situations. So I consider this construct to be a net win for simple OO Perl classes in many cases.

I also provide an alternative to it in (tye)Re: Private Class Methods.

- tye