in reply to
Re: (jeffa) 5Re: My first stab at OO perl...
in thread My first stab at OO perl...
Except that open can fail as a result of all kinds of things not under the control of the program(mer). Calling a constructor in a way that is not documented in the API for a module... well, if it works the way you expected it to, that's an undocumented feature. If it works, but not quite the way you wanted it to, that's a bug (in the mind of the programmer, anyway). If it just plain doesn't work, that's what one expects having read the documentation.
Personally, I'd go with the last of these. If your constructor contains a bit of unexpected magic, you may as well document it. And if you want to allow for $instance->new(), you'll have to
painstakingly document whether this creates a new "empty" object, or whether it creates a copy of the instance it was called on. FWIW, I think of "new" as a class method no matter what, so to my mind providing a way to use new from an instance is just muddying the water.
Notes on reply: my point is that you will need to document this behavior, otherwise there is no reason to include it. And I have no idea what this adds to the module or how it helps programmers. It seems only to add a layer of indirection, which Perl OO already has enough of (imho-- and hopefully this will improve in Perl 6).