Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
// lines
do
{
// many lines
if ( some_cond )
break;
// many lines
if ( other_cond )
break;
// lines
}
while (0);
// lines
if ( some_cond )
goto label_skip_some;
// lines
if ( other_cond )
goto label_skip_some;
// lines
label_skip_some:
if ( !some_cond )
func1();
// lines
if ( !other_cond )
func2();
if ( some_cond )
{
// lines
if ( other_cond )
{
// lines
}
}
state = new_state; break;учавствуют
обнаружаться
вой то поднимется
for x in range(0u, 5) outerLoop {
for y in range(0u, 5) innerLoop {
println!("{},{}", x, y);
if y == 3 {
break outerLoop;
}
}
}В C, например, на нём реализуются деструкторы, и лучшего решения действительно нет
var state = 'START';
for (;;) switch (state) {
case 'START':
state = 'NEXT';
break;
case 'NEXT':
state = 'STOP';
break;
case 'STOP':
return 'RESULT';
}
typedef enum {STATE1, STATE2..} tStateNum;
typedef void (*tProcessEvent)(void);
typedef struct
{
tStateNum current_state, next_state;
tProcessEvent process;
}tStateDescriptor;
tStateDescriptor States[]={...}
...
tStateDescriptor currState = ...
while (1)
{
currState->process();
currState = GetStateByNum(States, curr_state->next_state);
}
currState = &(States[curr_state->next_state]);
if (cond)
goto x;
T a = GetA();
x:
Display(a);
if(++nattempts<5) goto _retry;
throw new Exception("Failed to start motors in 5 attempts");
GOTO or not GOTO вот в чём вопрос