|Welcome to the Monastery|
Re^2: Is "ref($class) || $class" a bad thing?by stvn (Monsignor)
|on Jul 12, 2004 at 16:32 UTC||Need Help??|
The ref $proto || $proto idiom is not bad in and of itself. It's bad when it's tossed in around blindly without documentation because it suggests that perhaps the programmer is unaware of the intention.
But that implies that people will read said documenation and even more so that if they read it, they would understand it. That can be a heavy assumption. Of course, it could be argued that if they don't read it, it's their problem anyway.
Personally, I tend to be a paranoid programmer, and I am very concerned about my modules working as I intend and sending feeback/warnings/errors back to the user if they are not used correctly, regardless of the documenation.
As with anything in Perl (or even life), I would hate to automatically declare anything wholly without merit (with the possible exception of bell peppers -- they're just gross), so I'd argue that this idiom has it's place so long as someone knows why they've put it there.
I guess I am not arguing so much that the idiom is bad, but that maybe teaching it soooooo widely is. I know that I use it, and have never really stopped to consider the implications of it being misused (I mean, all the cooool kids use it ;-) . So yes, I am one of those people who didn't stop to think about why I put it there, but I am sure I am not alone. And I am also sure there are many new perl programmers, who will make the same mistake. When will the madness end!!!!!!
Of course, in the interest of full disclosure, I'm the guy who submitted the patch that had the ref $proto || $proto code mostly removed from the latest perldocs.
Excellent! Did the patch get accepted?