+ 2
Why whitespace such as spaces, tabs and newline is ignored while programming?
I asked this question because If spaces are ignored, it means int main () and intmain() are same but compiler gives us an error.
3 Réponses
+ 3
continuous white spaces are ignored so developers can make their code readable.
it does not matter how many spaces are there between two tokens but "intmain()" and "int main()" have a difference of being one and two tokens so the problem occurs.
+ 9
The compiler doesn't really ignore as it still need to parse/understand the syntax separated by space like you've mentioned.
It's just the case that MULTIPLE whitespaces is redundant or unnecessary as compiler still treat it the same.
+ 2
* Important note: All spaces are not whitespace. Compilers ignore whitespace, but not all spaces. An example is Python. You must put spaces for code blocks!
Considering note above, they aren't same (int main() and intmain()). Programming languages are the same as real languages.
How can you understand my sentence if I ignore all spaces between words? At least, it's so hard and takes down your reading speed.
Besides, you may read my sentence in a wrong way. If I merge two words, it would be readable in many ways.
Finally, consider we are humans, what you expect from bots and computers, better to say, parsers and compilers?