The cause of all this fuss was use of a function in an existing library that is mostly, for some reason, prototyped. This is real code, not some "hypothetical misdesign".
I hardly ever prototype, only when I have to, such as those examples you mention. I've used prototypes before, and they caused all sorts of
wierdness, so I stopped. This might have been when they were still considered neat and not inherently dangerous.
Because of this, I've come to rely on doing things like chaining functions together, not unlike your example, or saving repeated parameters in arrays. I don't suggest that you should expand your arrays into lists
just because. Not at all. What I'm saying is that
if the function is prototyped,
then you have no choice, which is another way of saying "sometimes you just have to". That's not my reasoning, that's reality! If you don't use prototypes, then this isn't an issue, and that's probably the best course of action. If you do, then you're going to have to be prepared for the consequences, so you'd better have a really good reason.
Although it probably wasn't clear, the whole point of the original post was to validate the theory that, if one can't
deprototype the target function, then the consequences are that you really have to do all this extra work to use that function properly. I was hoping for the programmatic equivalent of a rubber glove that could be used to idiomatically insulate code A from prototyped code B, but no such technique seems to be available. Not that I was depending on this, of course.
This is yet another reason why the widespread use of prototypes is not a great idea. In Perl 6, things look like they will be much smoother.
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.