Click here to Skip to main content
15,895,798 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Loop exit Pin
Matthew Barnett31-Jul-14 1:20
Matthew Barnett31-Jul-14 1:20 
GeneralRe: Loop exit Pin
kalberts31-Jul-14 23:11
kalberts31-Jul-14 23:11 
GeneralRe: Loop exit Pin
M. Eugene Andrews31-Jul-14 1:53
M. Eugene Andrews31-Jul-14 1:53 
GeneralRe: Loop exit Pin
crazedDotNetDev31-Jul-14 5:59
crazedDotNetDev31-Jul-14 5:59 
GeneralRe: Loop exit Pin
kalberts31-Jul-14 22:58
kalberts31-Jul-14 22:58 
GeneralRe: Loop exit Pin
crazedDotNetDev1-Aug-14 10:34
crazedDotNetDev1-Aug-14 10:34 
GeneralRe: Loop exit Pin
Member 460889831-Jul-14 5:58
Member 460889831-Jul-14 5:58 
GeneralRe: Loop exit Pin
kalberts31-Jul-14 22:57
kalberts31-Jul-14 22:57 
CHILL has a very nice solution to this: Every block, whether a procedure, loop, switch or even a linear sequence of statements enclosed with BEGIN and END, could be prefixed with a label. In CHILL, a label does not identify a point in the program, but a block, and consequently label scopes could be nested. So to leave the outer loop, you would write
SQL
OuterLoop: 
DO FOR (...) 

   InnerLoop: 
   DO FOR (...) 
      ...
      IF <done processing this element> THEN EXIT InnerLoop; FI;
      ...
      IF <some fatal condition> THEN EXIT OuterLoop; FI
      ...
   OD

OD

(Here I illustrate both leaving the inner loop and the outer loop.) However, CHILL doesn't provide what I asked for in my original post: If the post-loop processing depends on whether you completed the loop or left prematurely by EXIT, you must set some variable to a magic value and test it after the loop, and the post-loop processing would syntactically (e.g. with respect to variable scope) be outside the loop.

While we are at CHILL: Another nifty syntactic sugar cube is the keyword EVER:
C++
DO FOR EVER
   ...
OD

The semantics of EVER is quite obvious. I like this so much that whenever I need to program an inner loop in C, I set up a
C++
#define ever (;;)

to be able to code it as "for ever {...}" in C.

Sure, any well seasoned C programmer would prefer "while (1) {...}", but even though I have been writing more lines of C code than in any other language the last thirty years, I still read it as "while one what???"
GeneralRe: Loop exit Pin
dg6yhw1131-Jul-14 7:25
dg6yhw1131-Jul-14 7:25 
GeneralRe: Loop exit Pin
Frank Malcolm31-Jul-14 15:40
Frank Malcolm31-Jul-14 15:40 
GeneralRe: Loop exit Pin
kalberts31-Jul-14 22:19
kalberts31-Jul-14 22:19 
GeneralRe: Loop exit Pin
Frank Malcolm1-Aug-14 13:57
Frank Malcolm1-Aug-14 13:57 
GeneralDoing an interview today PinPopular
glennPattonWork329-Jul-14 22:49
professionalglennPattonWork329-Jul-14 22:49 
GeneralRe: Doing an interview today Pin
Argonia29-Jul-14 22:50
professionalArgonia29-Jul-14 22:50 
GeneralRe: Doing an interview today Pin
glennPattonWork329-Jul-14 22:57
professionalglennPattonWork329-Jul-14 22:57 
GeneralRe: Doing an interview today Pin
OriginalGriff29-Jul-14 22:50
mveOriginalGriff29-Jul-14 22:50 
GeneralRe: Doing an interview today Pin
glennPattonWork329-Jul-14 22:55
professionalglennPattonWork329-Jul-14 22:55 
GeneralRe: Doing an interview today Pin
Kornfeld Eliyahu Peter29-Jul-14 22:54
professionalKornfeld Eliyahu Peter29-Jul-14 22:54 
GeneralRe: Doing an interview today Pin
glennPattonWork329-Jul-14 23:00
professionalglennPattonWork329-Jul-14 23:00 
GeneralRe: Doing an interview today Pin
Kornfeld Eliyahu Peter29-Jul-14 23:14
professionalKornfeld Eliyahu Peter29-Jul-14 23:14 
GeneralRe: Doing an interview today Pin
_Maxxx_30-Jul-14 0:36
professional_Maxxx_30-Jul-14 0:36 
GeneralRe: Doing an interview today Pin
Dinesh.V.Kumar29-Jul-14 23:04
Dinesh.V.Kumar29-Jul-14 23:04 
GeneralRe: Doing an interview today Pin
Pete O'Hanlon29-Jul-14 23:13
mvePete O'Hanlon29-Jul-14 23:13 
GeneralRe: Doing an interview today Pin
Bergholt Stuttley Johnson29-Jul-14 23:18
professionalBergholt Stuttley Johnson29-Jul-14 23:18 
GeneralRe: Doing an interview today Pin
Mycroft Holmes29-Jul-14 23:25
professionalMycroft Holmes29-Jul-14 23:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.