in reply to What A Wonderful World: Bitmasks!
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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: What A Wonderful World: Bitmasks!
by demerphq (Chancellor) on Dec 09, 2002 at 01:07 UTC |