Jump to content


Simple text based game in C++


25 replies to this topic

#21 eddie

    Senior Member

  • Members
  • PipPipPipPip
  • 751 posts

Posted 14 July 2006 - 09:24 PM

Reedbeta said:

How silly is that?

I know! How can we be expected to learn, think or grow without knowing the function bodies? All it'll result in is a linker error!

<groan> :)

#22 Jare

    Valued Member

  • Members
  • PipPipPip
  • 247 posts

Posted 16 July 2006 - 10:00 PM

Ah, but continue's are evil! :) And it's better to

#define forever for( ; ; )

anyway. ;) Anyway, the point was that checking for an error condition and continuing anyway instead of providing a way to correct the error is bad practice most of the times.

#23 eddie

    Senior Member

  • Members
  • PipPipPipPip
  • 751 posts

Posted 16 July 2006 - 11:08 PM

Jare said:

Ah, but continue's are evil! :) And it's better to

#define forever for( ; ; )

anyway. ;) Anyway, the point was that checking for an error condition and continuing anyway instead of providing a way to correct the error is bad practice most of the times.

I hope you're being sarcastic. :)

There's nothing evil about continue -- in fact they're quite useful rather than using nesting to bloat out your code horizontally.

#define's are nasty, as they aren't scoped well. I forevermore can't use the identifier 'forever' in any of my code without coming up with some crazy syntax error, or worse yet, an unintentional infinite loop. Besides, 'while(1)' is barely more keystrokes, and doesn't cloud any identifiers.

That said, your final point is right. Make sure to get valid input before proceeding. :)

#24 Jare

    Valued Member

  • Members
  • PipPipPip
  • 247 posts

Posted 18 July 2006 - 10:46 PM

eddie said:

I hope you're being sarcastic. :) There's nothing evil about continue
Tongue-in-cheek rather than all-out sarcastic. I admit I have a certain irrational phobia to continues, akin to the outright hatred of gotos that most modern software people have. I only like continue statements when they are VERY visible, and in small loops, but that's a wholly different topic not really worthy of a discussion.

#25 eddie

    Senior Member

  • Members
  • PipPipPipPip
  • 751 posts

Posted 18 July 2006 - 11:12 PM

Fair enough. ;) I can see the issue with continues at times, but personally I loathe defines that aren't truly necessary. :)

#26 monjardin

    Senior Member

  • Members
  • PipPipPipPip
  • 1033 posts

Posted 19 July 2006 - 01:12 PM

I think you both have some well-founded paranoias. :p

I'm having to pick apart some US Government C-code with liberal use of gotos at the moment. I'd don't think they've ever heard of encapsulation. :( Goto code can be incredible difficult to reuse.

Continues on the other hand can cause confusion. However, I'd use either or both if they were the best way to solve a problem. :)
monjardin's JwN Meter (1,2,3,4,5,6):
|----|----|----|----|----|----|----|----|----|----|
*





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users