I don't have any particular problem with the concept of calling "class methods" with objects
Likewise. I don't have a problem with that, I don't find the distinction "class" method very useful in Perl. In the case of new giving the reader more information about the type of the object can ease the understanding of code using that object. The reason to make my suggested usage a habit is that code can grow, an intermediate call may be inserted into your code; or code-text may be added around your construct making pertinent info more remote; or the type-tree may expand making the code more abstract.
if I am faced with $obj->method, and I need to discern which instance of "method" is being called, I'm going to be in for some work, no matter what. If there are multiple modules that might have "sub method" in them, whether I say ref($obj)->method or not will not affect the order of magnitude of the search.
You are exactly right. But the writer who says (ref $obj->method is explicitly telling you that the search is necessary. And the writer who says $obj->new when he knew that Obj->new was equivalent is abusing you unnecessarily, certainly there are some cases where the abuse is very minor, until the code grows.
A nitpick:(ref $foo)->method($foo) is not quite the same as $foo->method; the first passes two arguments -- the second but one. The additional argument in the first form does not provide additional information, but it is not quite correct to say that they "pass the same info".
Counter-nit: As you say The additional argument ... does not provide additional information so the statement is correct. I was trying to avoid the word pass but everything else I thought of seemed to relate to informing the reader of the code, which seemed more misleading.
I ... may be ... a stubborn git.
I won't dispute this, we both have demonstrated, ahem, a willingness to argue at length over minor issues. In that willingness I see fortitude and some concern for others and for truth. I am trying to share a Good Thing. I am not finding new ways to be more convincing on this so I'll let the subject lie.
I certainly am not going to have angina over this subject, I hope steves is not too worried for me. :-)
In reply to (Re:)+ $class = ref $class || $class
by rir
in thread Constructor/Factory Orthodoxy
by mojotoad
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |