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).
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.