Jump to content
  • Advertisement
Sign in to follow this  
thugkilla

for (::)

This topic is 4815 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

Advertisement
It's an ugly infinite loop that is used because people think it is clever. Should you need to write an infinite loop some day, which you shouldn't, prefer while(true) for at least some kind of clarity.

Share this post


Link to post
Share on other sites
Quote:
Original post by xMcBaiNx
It's an ugly infinite loop that is used because people think it is clever. Should you need to write an infinite loop some day, which you shouldn't, prefer while(true) for at least some kind of clarity.

It's not an ugly way. It's the standard C and C++ way to do an infinite loop. That, and sometimes it's perfectly valid to create an infinite loop (with a breaking condition inside, of course).

Share this post


Link to post
Share on other sites
Quote:
Original post by xMcBaiNx
Should you need to write an infinite loop some day, which you shouldn't...

Rot. Infinite loops with breaking conditions are the proper way to handle, for instance, non-Win32 game/application main loops with multiple exit conditions.

Quote:
Original post by Coder
It's not an ugly way. It's the standard C and C++ way to do an infinite loop.

That's unfortunate, as while (true) is semantically clearer. It is apparently implementation-defined whether the two constructs generate identical code, which is also unfortunate.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!