Hi,
thank you for sharing that, was not where of that, because c/c++ specification labels are limited as I pulled the specification to be within block scope, as there are limitation of using goto can be used.
After testing this is my problem with the code and specification, which limits what is possible
never the less, this is already good to know, as in c continue is equivalent of goto, has not properly been integrated with for loop control like javascript has, however, still feel there is room for improvement, which gives us the correct ganulaity of control.
c++ breaking or goto the mostouter will have your program running indefinitely. as is different in meaning.
labelled object literal is great because break as if this was an early return function, but without having to nest an anonymous functions
-
continue with a label, performs breaks and the last loop is a continuous behaviour, one still wants granularity of control here, because could have global scope variables, in which break, break, continue behaviour is not desired.
-
break in a loop, stops execution and skips the final conditional check, incremental step as per normal.
-
labels must be anywhere in the loop or outside section as long it now across function bounderies, obviously continue has the constraint of above the previous loop start. can't break to label brace section from outside the block scope.
4.skip, is required because break is basically only to parent block section label or an object literal bracet block, which allow for finer grain control.
- Chaning of break and continue statements, such that different behaviour of exiting multiple neasted loops can be achieved, so get program behaviour that one desires. continue 3 loops, out may not be want ones wants, with have more global variables.
mostLoop: for (let i = 0; i < 5; i++) {
console.log("SkipContinue");
/* breakHere:{
console.log("breakHere");
}*/
console.log("runCOntinue");
outerLoop: for (let j = 0; console.log("outerCondition") || j < 5; j++, console.log("outerLoopPosRepeatStep")) {
console.log("outerinnerbefore");
innerLoop: for (let k = 0; console.log("innerCondition") || k < 5; k++, console.log("innerLoopPosRepeatStep")) {
console.log("K" + i + ":" + j + ":" + k);
// continue innerLoop;
//continue outerLoop;
//break outerLoop;
break mostLoop;
console.log("SkipK");
}
console.log("outerinnerpost");
}
}
test1: {
console.log("test1");
break test2
console.log("test1postbreak");
}
test2: {
console.log("test2")
}