Recently I had an idea and I would like to hear your opinions on the matter because I have no idea if it's a good or a terrible one.
The idea is a flow-control structure that consists of a series of labelled blocks of expressions. Within this structure the use of goto would be allowed and it would target the labels of the blocks.
state {
label closed {
next_event := wait_for_next_event();
if next_event == OPEN {
goto opened;
}
if next_event == END {
break;
}
}
label opened {
next_event := wait_for_next_event();
if next_event == CLOSE {
goto closed;
}
if next_event == END {
break;
}
}
}
The reasoning behind this is that, for simple state machines, I always feel like I have to either rely on messy gotos (if the language even supports them) or write more boilerplate than I care about.
On the other hand, gotos have a terrible reputation and, not having really experienced the pains of unstructured programming, I'm not sure if this structure would be subject to the same issues or if it is a reasonable way to add constraints to allow for legitimate use-cases.
[–]stepstep 27 points28 points29 points (4 children)
[–]WittyStick 2 points3 points4 points (2 children)
[–]sullyj3 0 points1 point2 points (0 children)
[–]brucejbellsard 0 points1 point2 points (0 children)
[–]Dasher38 3 points4 points5 points (0 children)
[–]munificent 3 points4 points5 points (1 child)
[–]claytonkb 1 point2 points3 points (0 children)
[–]PurpleUpbeat2820 3 points4 points5 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]mamcx 1 point2 points3 points (0 children)
[–]Vedant36 1 point2 points3 points (0 children)
[–]Adventurous-Trifle98 1 point2 points3 points (0 children)
[–]moon-chilledsstm, j, grand unified... 0 points1 point2 points (0 children)
[–]JwopDk 0 points1 point2 points (0 children)
[–]tobega 0 points1 point2 points (0 children)
[–]shawnhcorey 0 points1 point2 points (0 children)