Click here to Skip to main content
15,888,351 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: undefined reference - please help with linker issue Pin
Richard Andrew x6411-Apr-24 9:25
professionalRichard Andrew x6411-Apr-24 9:25 
AnswerRe: undefined reference - please help with linker issue Pin
Richard MacCutchan11-Apr-24 21:01
mveRichard MacCutchan11-Apr-24 21:01 
QuestionBreak in a for loop Pin
Calin Negru11-Apr-24 1:19
Calin Negru11-Apr-24 1:19 
AnswerRe: Break in a for loop Pin
Mircea Neacsu11-Apr-24 1:28
Mircea Neacsu11-Apr-24 1:28 
AnswerRe: Break in a for loop Pin
Maximilien11-Apr-24 2:43
Maximilien11-Apr-24 2:43 
GeneralRe: Break in a for loop Pin
Calin Negru11-Apr-24 3:08
Calin Negru11-Apr-24 3:08 
GeneralRe: Break in a for loop Pin
CPallini11-Apr-24 4:17
mveCPallini11-Apr-24 4:17 
GeneralRe: Break in a for loop Pin
trønderen11-Apr-24 7:30
trønderen11-Apr-24 7:30 
Maximilien wrote:
Probably one of the last valid usecase for goto. Especially if more than 2 inner loops.
There were lots of valid 'goto' use cases cases, before for loops, while loops, and arbitrarily nested if-else, were invented.

Structured exit from multiply nested loops were invented 40+ years ago. In 1980 vintage CHILL, you could do
C++
outermost:     <loop control outermost>
                 <outermost statements>

intermediate:    <loop control intermediate>
                   <intermediate statements>

inner:             <loop control inner>
                     <statements>
                     exit intermediate;
                   <end inner>

                   <more intermediate statements>
                 <end intermediate>

                 <more outermost statements>
                <end outermost>
exit intermediate; would skip the "more intermediate statements" as well as further intermediate iterations, going directly to "more outermost statements" and continue with further outermost iterations.
If it rather said exit outermost;, the "more outermost statements" would be skipped as well, and the outermost loop would be left.
exit would be a short form of exit innermost;

This construct never made it into mainstream language such as the C derived ones. One partial explanation is differences in label semantics: In CHILL, a label identifies a block, not a point in the code. Furthermore, a statement is a block; it need not be embraced to be labeled.

I would be willing to trade a lot of other 'improvements' in more recent language extensions in favor of something like this.

Some concepts were not well developed in 1980. If a language of today were to introduce such a multi-level exit, it would probably come with something 'finally'-like mechanisms to do required cleanup operations regardless of loop exit method.

Religious freedom is the freedom to say that two plus two make five.

GeneralRe: Break in a for loop Pin
Greg Utas11-Apr-24 7:50
professionalGreg Utas11-Apr-24 7:50 
AnswerRe: Break in a for loop Pin
BernardIE531717-Apr-24 12:01
BernardIE531717-Apr-24 12:01 
Question#define #undefine #define sequence result ? Pin
Salvatore Terress10-Apr-24 5:12
Salvatore Terress10-Apr-24 5:12 
AnswerRe: #define #undefine #define sequence result ? Pin
Mircea Neacsu10-Apr-24 5:14
Mircea Neacsu10-Apr-24 5:14 
AnswerRe: #define #undefine #define sequence result ? Pin
Richard MacCutchan10-Apr-24 6:36
mveRichard MacCutchan10-Apr-24 6:36 
AnswerRe: #define #undefine #define sequence result ? Pin
Salvatore Terress10-Apr-24 7:28
Salvatore Terress10-Apr-24 7:28 
AnswerRe: #define #undefine #define sequence result ? Pin
Salvatore Terress10-Apr-24 7:28
Salvatore Terress10-Apr-24 7:28 
Question#include - again Pin
Salvatore Terress5-Apr-24 5:06
Salvatore Terress5-Apr-24 5:06 
AnswerRe: #include - again Pin
Richard MacCutchan5-Apr-24 5:10
mveRichard MacCutchan5-Apr-24 5:10 
AnswerRe: #include - again Pin
Mircea Neacsu5-Apr-24 5:28
Mircea Neacsu5-Apr-24 5:28 
GeneralRe: #include - again Pin
trønderen5-Apr-24 6:01
trønderen5-Apr-24 6:01 
GeneralRe: #include - again Pin
trønderen5-Apr-24 6:14
trønderen5-Apr-24 6:14 
GeneralRe: #include - again Pin
Salvatore Terress10-Apr-24 5:03
Salvatore Terress10-Apr-24 5:03 
GeneralRe: #include - again Pin
trønderen10-Apr-24 6:53
trønderen10-Apr-24 6:53 
GeneralRe: #include - again Pin
BernardIE531717-Apr-24 12:11
BernardIE531717-Apr-24 12:11 
GeneralRe: #include - again Pin
k505410-Apr-24 6:35
mvek505410-Apr-24 6:35 
GeneralRe: #include - again Pin
trønderen10-Apr-24 7:11
trønderen10-Apr-24 7:11 

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.