3 ms·
"Compiler writers are sometimes surprisingly clueless about programming." Sure, but there's another aspect, which is trying to guess at what the minimum level
by WalterBright 8y ago
"Compiler writers are sometimes surprisingly clueless about programming."
Sure, but there's another aspect, which is trying to guess at what the minimum level of knowledge the user of the language should be expected to have. For an interesting debate on if an "isOdd(int i)" as opposed to just using (i & 1) should exist as a standard library component or not, see:
https://digitalmars.com/d/archives/digitalmars/D/food_for_thought_-_swift_5_released_-_bottom_types_string_325712.html#N325778 https://digitalmars.com/d/archives/digitalmars/D/food_for_th...
- earenndil 8y agofunction isEven(int i) { return !isOdd(i); }
- earenndil 8y ago> For example, if I saw "isOdd" in code, I'd wonder what the heck that was doing. I'd go look up its documentation, implementation, test cases, etc., find out "oh, it's just doing the obvious thing", and be annoyed at the waste of my time. Huh. That is not at all what I would do. I would think 'oh, that's checking if the thing is odd' and keep going. If I see i&1, then I have to unpack that, parse it, figure out why it's there and that it checks oddness. Also relevant is that i&1 checking if i is odd is a detail of i's internal representation. There's nothing intrinsically odd-related about the operation &1; that it checks for oddness is a co-incidental side effect, just like how making a truth table of (0, 0) => 0, (1, 0) => 1, (0, 1) => 1, (1, 1) => 1 happens to correctly simulate the behaviour of an or logic gate, even though there's nothing inherently or-y about it.