On Mon, Feb 10, 2014 at 10:07 PM, shawn wilson <ag4ve...@gmail.com> wrote:

>  which I still don't see why this is bad?

In "classic" object-oriented programming, object constructors -- which
is what new() is in your class -- are always class methods. Calling
'new()' as an object method doesn't make any sense. Further, as Uri
points out, the semantics can get confused when you call a 'new()'
method on an object. Are you asking for a new, fresh instance of an
object of the class that the existing object is a member of, or are
you asking for a a new instance that's a copy of the object you're
calling the method on?

(Aside: that confusion is the reason why Uri is suggesting an object
method called 'clone()'. I can only assume he's intending for it to
return a copy of the object it is called on, not a completely fresh
instance of the object defined by the class of the object that it is
called on.)

TL;DR - if you can't offer a positive reason why you're doing this --
and "it doesn't seem to hurt anything" is *not* a positive reason --
then you shouldn't do it.

j.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to