Whitespace
I have been told 2 things about whitespace in a program:
1. Whitespace serves only to make your program more easy to read and has no effect on your program
2. Whitespace DOES have an effect on your program
Which is true?
Depends which language. Python, for example, relies heavily on whitespace to determine scope. C++, on the other hand, does not use it at all (except for rare cases).
Whitespace serves only to make your program more easy to read and has no effect on your program. The only time it should have an effect on your program is if you have it within quotes, " ", in C++ of course, and C.
Most whitespace has no effect on your program in most languages. The most common case in C-style syntaxes is something like >> vs. > > .
In C or C++ neither whitespace nor comments have an effect on the compiled program.
Whitespace is defined as the space between function names, arguments, types, keywords, class names, operators or any other identifiers. Wherever a single space is valid, many spaces or line breaks will also be valid.
*edit: and as the above poster mentioned, you require at least one space between each identifier.
Whitespace is defined as the space between function names, arguments, types, keywords, class names, operators or any other identifiers. Wherever a single space is valid, many spaces or line breaks will also be valid.
*edit: and as the above poster mentioned, you require at least one space between each identifier.
Indeed, thanks all for your comments
Just figured I'd double check that before I went and did anything stupid with my coding skills.
Just figured I'd double check that before I went and did anything stupid with my coding skills.
Use whitespace liberally. The primary function of modern production code is to communicate with other programmers. Whitespace makes that easier.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement