• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

loops

 
boopathy Gopalsamy
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
could any of u tell why this code doesn't produce an unreachable statement error.

code snippet:
do
for(;true ;
while(true)
 
Mike Gershman
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which statement do you think is unreachable?
 
Simon Cockayne
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I see a SMILEY face in the example code. So I am not sure what the syntax was supposed to look like...

Is this because the code is not added within CODE tags?

Cheers,

Si.
 
Jeff Tian
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any code that you have after that do while loop will be unreachable.
 
Carol Enderlin
drifter
Ranch Hand
Posts: 1364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can check the "Disable smilies in this post" checkbox to make that kind of thing readable.

And use the pencil icon to go back and edit it.
[ March 29, 2005: Message edited by: Carol Enderlin ]
 
Mike Gershman
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If there are no statements after the while clause, there are no unreachable statements.
 
Jeff Jetton
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I've reposted what I think the original poster's code is.

So the "for" loop is infinite, right? So wouldn't the "while" clause itself be unreachable? Or does the compiler evaluate the "while" before it moves in to look at what inside the loop?

- Jeff
[ March 30, 2005: Message edited by: Jeff Jetton ]
 
Animesh Shrivastava
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The compiler just checks here if do statement is reachable or not, The do statement here meaning do-while. So u cant seperate out do and while, its the same.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic