3 ms·
Again, would you say the same thing about registers versus stack allocation (or heap allocation)? "The CPU handles it differently" isn't by itself a legitimate
by pcwalton 12y ago
Again, would you say the same thing about registers versus stack allocation (or heap allocation)?
"The CPU handles it differently" isn't by itself a legitimate argument against abstraction.
- Nitramp 12y agoThis code is converting a bunch of bytes into an integer by bit shifting. So it's specific to the binary representation of ints in your language, and how types of various sizes and signedness interact. Note that this doesn't depend on your CPU, but rather on how integers and their byte representations are specified in the language. I think it's quite reasonable to expect the programmer to know what that means assuming they are writing bitfiddling code like this.
- pcwalton 12y agoNone of that argues against abstraction. It's perfectly reasonable to want to write code that uses left bitshift and works on unsigned and signed 8, 16, 32, and 64 bit integers.