I argue that return (0); is better than a simple () or bare "return;"

Why? What would the advantage of that be?? The disadvantage has been discussed in this thread.

One of the pages that talks about this: Hooks.

Sorry, but that page only contradicts your argument. Nowhere is a guarantee made as to which context the hooks are called in (the documentation of the callback on_osc_seq even explicitly says "The default should be to return an empty list."). The page explicitly says "All of these hooks must return a boolean value. ... When in doubt, return a false value (preferably ())." As per Truth and Falsehood, the false values in Perl are: "The number 0, the strings '0' and "", the empty list (), and undef". A list with one element is true, and so again, return 0 is not always false!

Further I argue that your interpretation of the intent is wrong. If the author of the documentation wanted you to return 1 or 0, or if the hooks were always evaluated in scalar context, he/she would have said so. By deliberately telling users to return the empty list (), they are, for example, keeping the door open for the hooks API to be more easily extended in the future - hooks could return multiple values.


In reply to Re^4: What could make "()" a good value for boolean false? by Anonymous Monk
in thread What could make "()" a good value for boolean false? by morgon

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.