- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Can I get a wonder hat? Are they available on your website?
Admin
Clearly the mouse did exist at one point, then it met meowcow moocat and either got squished or eaten.
Admin
I rather prefer 1<<0 to indicate it is a bitmask. Yes the variable says 'mask' as well, but it is a cheap, no overhead, way to insure the proper mindset for the next person reading it.
Admin
const commentExisted = ()=>{ return 0; };
Admin
Agreed. It is so important to help the next developer. Also, not everyone knows about bit shifting. So it’s a learning moment too.
Admin
Or, alternatively, you could define a bitmask as follows:
There are better ways to express intent than to randomly abuse operators. (Although if you're phoning a support line, I recommend that latter practise. You won't get help, but at least you'll feel better.)
Admin
I tried to emphasize to my students years back that the form of a constant mattered. Hopefully it's obvious that 65, 0x41 and 'A' are all the same number, but convey different intentions. sigh But then there's the time I had to strip out all the bitmasks enumerated in decimal.
Admin
"hat the meaning of all of this actually is". Hat is actually the meaning of this all.
H,a,t,EOT = 65+97-116-4 = 42.
It checks out! It all makes sense now!
Admin
Ref
Without knowing how many other lines of the general form
occur in their codebase in general and this source file in particular we can't tell if this is dumb or a sensible pattern being consistently applied.
Admin
No, it's not obvious at all. 'A' == 0xC1.
https://en.wikipedia.org/wiki/EBCDIC#Code_page_layout
Admin
Wow, there are so many EBCDIC codes that aren't included in Unicode.
Admin
I would submit that using a signed type for the target of a bit-shifting operation is incontrovertibly dumb. Furthermore, it's dangerous. (See various language standards.)
I'll try again on the concept of enforcing the concept that "this is a bit-shift:"
Pretty much all modern compilers or jitters will inline this, even if the language does not support explicit inlining. Not all languages support an optional parameter of this kind, but that's me just being finicky.
I don't need to see the rest of the code base. Definitionally, this is a dumb pattern.
Admin
Three comments above held for moderation and the one in the middle that isn't is spam ... just why
Admin
No, you need to ENSURE the proper mindset. INsuring the proper mindset is building a system to catch a known pre-planned catestrophic failure, and going back to pick up all the pieces. Software should as far as possible never INsure for stuff failing, it should as much as possible ENsure stuff happens correctly.