Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You have to think about this from the perspective of a writer -- know your audience. So there are a couple of "audiences" to consider. </p> <p>First there's the classic C programmer, who have bitmasked their whole lives and could do it in their sleep. </p> <p>Second there's the newb, who has no idea what all this |, &amp; stuff is. They were programming php at their last job and now they work for you. (I say this as a newb who does php)</p> <p>If you write to satisfy the first audience (that is bitmask-all-day-long), you'll make them very happy, and they'll be able to maintain the code blindfolded. However, the newb will likely need to overcome a large learning curve before they are able to maintain your code. They will need to learn about binary operators, how you use these operations to set/clear bits, etc. You're almost certainly going to have bugs introduced by the newb as he/she all the tricks required to get this to work.</p> <p>On the other hand, if you write to satisfy the second audience, the newbs will have an easier time maintaining the code. They'll have an easier time groking</p> <pre><code> flags.force = 0; </code></pre> <p>than</p> <pre><code> flags &amp;= 0xFFFFFFFE; </code></pre> <p>and the first audience will just get grumpy, but its hard to imagine they wouldn't be able to grok and maintain the new syntax. It's just much harder to screw up. There won't be new bugs, because the newb will more easily maintain the code. You'll just get lectures about how "back in my day you needed a steady hand and a magnetized needle to set bits... we didn't even HAVE bitmasks!" (thanks <a href="http://xkcd.com/378/" rel="noreferrer">XKCD</a>).</p> <p>So I would strongly recommend using the fields over the bitmasks to newb-safe your code.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload