I'd probably expect $foo->new to clone $foo, but if the class author wanted that functionality they should have created an object method called "clone" or something like that.That, I do not understand. If you expect the author to name clone functionality clone, then why assume that new clones the object?
I'd expect something called new to give me a new thing - not a cloned one.
Well, you can always use (ref $foo)->new if that's what you want.That's not much of an argument, is it? With such an argument, we could do away with for/foreach, unless, and/or, q/qq/qw/qx, etc. There are always alternatives taking a few more keystrokes.
And note that the existance of ref $proto || $proto in a constructor doesn't prevent you from writing:
if(ref $foo)->new
confuses you.$foo->new
But the absense of ref $proto || $proto forces someone who doesn't confuse easily to write:
Ergo, using ref $proto || $proto gives the user of the module more choice.(ref $foo)->new
In reply to Re^4: bless with => separated args
by Anonymous Monk
in thread bless with => separated args
by jaa
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |