But can you name any example where !!$test doesn't return 1 or ''/0 currently?

Overloaded operators can do this.* I'm talking about properly written overloaded operators, not ones that try to repurpose "!". It's not an issue here and it's not likely to ever be an issue, which is why that's not the argument I chose to make.

What I did focus on is the writing of unreadable code to save one character. I find it too demanding of your reader to know that "!" returns +1 for true given the lack of cost of not demanding this knowledge.

The cost of confusion is low, but so is the cost of avoiding it.

* —

package Boolean; my $true = bless(\(my $data = -1)); # Like BASIC my $false = bless(\(my $data = 0)); use overload '!' => sub { ${$_[0]} ? $false : $true }, 'bool' => sub { ${$_[0]} }; sub boolean($) { $_[0] ? $true : $false } sub true() { $true } sub false() { $false } 1;

In reply to Re^6: Complex conditional sort by ikegami
in thread Complex conditional sort by Zhris

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.