▲ 911 ▼ I wish (i.imgur.com) submitted 2 years ago by nave@lemmy.zip to c/lemmyshitpost@lemmy.world 187 comments fedilink hide all child comments
[–] BeigeAgenda@lemmy.ca 7 points 2 years ago (1 child) I call it making assumptions that may be incorrect, and do you know if the compiler will do the optimization anyway in this case? permalink fedilink source parent hideshow 2 child comments replies: [–] mryessir@lemmy.sdf.org 0 points 2 years ago* (3 children) What statement do you flag as assumption? Yes, I do. The modulo operator is only a subset of bit masks. It is more explicit to write: if ( (variable &EVEN_MASK) == 0) ... To act upon even numbers then: if ( (variable %2) == 0) ... How would you name the 2 in the above statement for more expressive power? EVEN_MODULO_OP ? That may throw more people off imo. permalink fedilink source parent hideshow 6 child comments replies: [–] kogasa@programming.dev 10 points 2 years ago You shouldn't rename 2 at all. "Even" has a commonly understood meaning that is instantly recognizable from (variable %2) == 0. The bitmask is an overgeneralization. permalink fedilink source parent [–] mrbaby@lemmy.world 4 points 2 years ago Psh screw those people, they need to see my massive coder wang if(!i&1){ ... } permalink fedilink source parent [–] BeigeAgenda@lemmy.ca 1 point 2 years ago (1 child) I give up, I was wrong to even think about the modulo operator, you are clearly the master programmer. 🥇 This reminds me of a discussion about the ternary operator ? :, some people think its the one true way of writing code because its just so clear what it does. And I say please use it sparingly because if you start doing nested ternary operators its very hard to unpack what your code does, and I prefer readability over compact code, especially with today's compilers. permalink fedilink source parent hideshow 2 child comments replies: [–] uranibaba@lemmy.world 3 points 2 years ago I feel you said about JavaScript as a whole. permalink fedilink source parent
[–] mryessir@lemmy.sdf.org 0 points 2 years ago* (3 children) What statement do you flag as assumption? Yes, I do. The modulo operator is only a subset of bit masks. It is more explicit to write: if ( (variable &EVEN_MASK) == 0) ... To act upon even numbers then: if ( (variable %2) == 0) ... How would you name the 2 in the above statement for more expressive power? EVEN_MODULO_OP ? That may throw more people off imo. permalink fedilink source parent hideshow 6 child comments replies: [–] kogasa@programming.dev 10 points 2 years ago You shouldn't rename 2 at all. "Even" has a commonly understood meaning that is instantly recognizable from (variable %2) == 0. The bitmask is an overgeneralization. permalink fedilink source parent [–] mrbaby@lemmy.world 4 points 2 years ago Psh screw those people, they need to see my massive coder wang if(!i&1){ ... } permalink fedilink source parent [–] BeigeAgenda@lemmy.ca 1 point 2 years ago (1 child) I give up, I was wrong to even think about the modulo operator, you are clearly the master programmer. 🥇 This reminds me of a discussion about the ternary operator ? :, some people think its the one true way of writing code because its just so clear what it does. And I say please use it sparingly because if you start doing nested ternary operators its very hard to unpack what your code does, and I prefer readability over compact code, especially with today's compilers. permalink fedilink source parent hideshow 2 child comments replies: [–] uranibaba@lemmy.world 3 points 2 years ago I feel you said about JavaScript as a whole. permalink fedilink source parent
[–] kogasa@programming.dev 10 points 2 years ago You shouldn't rename 2 at all. "Even" has a commonly understood meaning that is instantly recognizable from (variable %2) == 0. The bitmask is an overgeneralization. permalink fedilink source parent
[–] mrbaby@lemmy.world 4 points 2 years ago Psh screw those people, they need to see my massive coder wang if(!i&1){ ... } permalink fedilink source parent
[–] BeigeAgenda@lemmy.ca 1 point 2 years ago (1 child) I give up, I was wrong to even think about the modulo operator, you are clearly the master programmer. 🥇 This reminds me of a discussion about the ternary operator ? :, some people think its the one true way of writing code because its just so clear what it does. And I say please use it sparingly because if you start doing nested ternary operators its very hard to unpack what your code does, and I prefer readability over compact code, especially with today's compilers. permalink fedilink source parent hideshow 2 child comments replies: [–] uranibaba@lemmy.world 3 points 2 years ago I feel you said about JavaScript as a whole. permalink fedilink source parent
[–] uranibaba@lemmy.world 3 points 2 years ago I feel you said about JavaScript as a whole. permalink fedilink source parent