If you don't like user subs returning different things depending on context, what is your feeling about buildins? If you don't like the fact buildins have different behaviour depending on context, why do you program in Perl? But if you don't mind, why do you mind if user subs do?

Good questions.

I think that built-ins can have different rules basically because they are built-ins, they are well documented, and they are finite. I have not memorized all the myriad ways that they change their behavior (see On Scalar Context), but I certainly know all the ones I've encountered with any frequency, and a lot of them do what I expected to begin with.

Adapting to the behavior of Perl built-ins is easy and well worth it. There aren't that many strange behaviors, they're all well documented, and I use them over and over.

User code, on the other hand, is mostly unknown, often poorly documented (if at all), far more vast, and far less useful. I don't want to have to be suspicious of every one of every sub I might encounter, and since the code I work on is not documented very well, I rely on examples from the code to tell me how something is to be used. There's more of it that I have to check, and the payoff is not very great because I won't spend my whole career working with it.


In reply to Re^2: Use of wantarray Considered Harmful by kyle
in thread Use of wantarray Considered Harmful by kyle

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.