Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: What A Wonderful World: Bitmasks!by theorbtwo (Prior) |
on Dec 08, 2002 at 08:11 UTC ( [id://218351]=note: print w/replies, xml ) | Need Help?? |
More cons, in addition to chromatic's: You can only have 32 flags without requiring two flag words (64 bits on some platforms, with some compilation flags and versions of perl -- a maintance nightmare). You could accidently use the wrong flags for the puticular function you're using, and it'll simply do the wrong thing silently -- no error, no possible way to catch it. Bitmasks absolutely have uses, don't get me wrong -- when you're in a C struct, and want to have room for expansion without making the struct larger. When space is at a premium -- if you were going to make an array of thoustands of items, using bitmasks instead of individual flag keys in a hash would make sense. But for function args, I'd use a hash of flags. Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).
In Section
Meditations
|
|