what's the point? do{...}while(FALSE);
-
The difference is that the above code is entitled to stand on the top position of the Coding Horrors forum.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarkemodified on Friday, February 8, 2008 3:06 PM
-
I've come across some code that is structured like this: do { //stuff... } while(FALSE); What's the difference between that and just doing the items that are in stuff WITHOUT the do-while(FALSE) "loop"?:confused:
-
Just figured it out. Interspersed within the {..} are #define'd a macro (ESCAPEIF(returnvalue) calls. It's defined to 'break' if an error occurrs. At the end of the function is the cleanup thus: do { ret = foo(); //returns a '1' BREAKONERROR(ret); } WHILE(FALSE); //perform cleanup (ie: release memory where needed) Guess I should have followed the white rabbit a little more ..or took the bluepill.
-
I've come across some code that is structured like this: do { //stuff... } while(FALSE); What's the difference between that and just doing the items that are in stuff WITHOUT the do-while(FALSE) "loop"?:confused:
It's better than using the ugly
GOTO
method. In a loop you have the option of usingbreak
andcontinue
. In this case it's a loop to be run once, unless directed to do otherwise.Waldermort
-
CPallini wrote:
the Coding Orrors forum.
What means "Coding Orros"? I know what Coding Oreos[^] are but never heard of Coding Orros.
led mike
led mike wrote:
What means "Coding Orros"?
Coding Orros refers to members of a family tree: http://www.genealogytoday.com/surname/finder.mv?Surname=Orros[^] who are better at making pizza than coding. http://www.yellowbot.com/orros-pizza-grill-saint-johns-fl.html[^] although obvious to us, it was not obvious to them. After seeing the pizza examples in head-first-design-patterns, you begin to realize how they thought that any pizza maker is automatically a programmer. As you see, the results of pizza makers writing software is extra cheese in our code. :-D
_________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
-
CPallini wrote:
the Coding Orrors forum.
What means "Coding Orros"? I know what Coding Oreos[^] are but never heard of Coding Orros.
led mike
And I even made it bold. :-O :sigh:
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
And I even made it bold. :-O :sigh:
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
It's better than using the ugly
GOTO
method. In a loop you have the option of usingbreak
andcontinue
. In this case it's a loop to be run once, unless directed to do otherwise.Waldermort
-
It's better than using the ugly
GOTO
method. In a loop you have the option of usingbreak
andcontinue
. In this case it's a loop to be run once, unless directed to do otherwise.Waldermort
WalderMt's better than using the ugly GOTO method.
I agree that this code is most probably the replacement for
goto
, but dissagree that it is better. It is even worse, because it hides the intention. -
Just figured it out. Interspersed within the {..} are #define'd a macro (ESCAPEIF(returnvalue) calls. It's defined to 'break' if an error occurrs. At the end of the function is the cleanup thus: do { ret = foo(); //returns a '1' BREAKONERROR(ret); } WHILE(FALSE); //perform cleanup (ie: release memory where needed) Guess I should have followed the white rabbit a little more ..or took the bluepill.
goto
is better.If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
goto
is better.If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
goto
is better.If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarkegoto
is dangerous in C++ if care is not taken because jumping out of scope will NOT result in the destructors of any C++ objects in the scope.Steve
-
goto
is dangerous in C++ if care is not taken because jumping out of scope will NOT result in the destructors of any C++ objects in the scope.Steve
C++
hastry
-catch
blocks, usuallygoto
is not needed. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke