In addition to the excellent responses from chromatic, theorbtwo and dws, I'd like to point out one further potential problem.

I frequently find that it's valuable -- at least in initialization -- to have three values for my user parameters -- true, false, and undefined, so I can tell the difference between never set and false.

Bitmasks default to 0 (at least, that is the usual convention), and from inside my initializer, I can't tell whether the user neglected to set (e.g.) COW or if s/he explictly set !COW. So distinguishing undef in this three-valued system allows me to detect the neglect case and set a default or carp appropriately.

Hmm... on reflection, I wonder how many other languages provide this useful distinction? C certainly doesn't, and it's a recurring PITA in my work there. I find Perl's distinction in this domain (a built in trinary Boolean value, if you will) to be one of its truly endearing features.

Just my $0.02 US.


In reply to Re: What A Wonderful World: Bitmasks! by jkahn
in thread What A Wonderful World: Bitmasks! by Revelation

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.