Keep It Simple, Stupid | |
PerlMonks |
Re: What A Wonderful World: Bitmasks!by jkahn (Friar) |
on Dec 08, 2002 at 21:27 UTC ( [id://218397]=note: print w/replies, xml ) | Need Help?? |
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 Section
Meditations
|
|