Jump to content
  • Advertisement
Sign in to follow this  
Steveosaurous

Whitespace

This topic is 4308 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
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).

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Most whitespace has no effect on your program in most languages. The most common case in C-style syntaxes is something like >> vs. > > .

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Use whitespace liberally. The primary function of modern production code is to communicate with other programmers. Whitespace makes that easier.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!