4 ms·
How can a compiler warn you that your thinking is wrong unless that thinking breaks some language rule or does something worth warning you about? The problem p
by fredsanford 13y ago
How can a compiler warn you that your thinking is wrong unless that thinking breaks some language rule or does something worth warning you about?
The problem presented in the article is not well thought out and cannot be achieved with these instructions:
Write down your name.
Make a pile of pennies with as many pennies as there are letters in your name.
Keep doing this:
Write down an 'X'
Remove one of the pennies
as long as the number of pennies is less than the number of letters in your name.
So, outside of being a mind-reader how is a C++ compiler supposed to correct _your_ thinking?
- PhasmaFelis 13y agoA lot of people seem to be hung up on the specific word problem he used. That's not really the point. The point is, if you do this: int foo = -1 unsigned int bar = 1 then "foo > bar" evaluates true. And it shouldn't, because that makes no sense. Languages should not violate the Principle of Least Surprise unless there's a really good reason.
- PhasmaFelis 13y agoAnd speaking of the Principle of Least Surprise, I'm curious as to why HN's comment system handles double newlines like a comment system, but single newlines like an HTML parser.