An attempt at alleviating the dangers of Goto (GotoConsideredHarmful
) and ComeFrom
), by combining the two into something a little more strict. The basic concept is that each GoTo
has a list of targets/sources - GoTo
's must be mentioned by the target ComeFrom
clause, or else the GoTo
is illegal (compiler-enforced).
In serial languages, it'd be sensible to only allow one target for each GoTo
, and only let one ComeFrom
reference a single GoTo
label. In a parallel language, just insert thread spawning where appropriate :P
T *X1, *X2;
X1 = (T*)malloc(...);
func1_failed: goto clean1;
X2 = (T*)malloc(...);
func2_failed: goto clean2;
clean2: comefrom func2_failed, func3_failed, ...;
clean1: comefrom func1_failed, funcX_failed, ...;
See, that's just soo
readable, isn't it? Might put this in my next language, unless I go with swap/cc instead (goto^comefrom is a bit too self-documenting for that language's goals :P) I'm hardly plagued by the simultaneous ugliness and self-documentativeness of the construct. Is this made for a serious language or for a prank language? *Dunno*
Some ideas for extensions:
- Add a when ... clause, kind of like Ada's entry conditions (you'd probably want it so that the conditions have to be compile-time enforcible though... at least in a C-style language)
clean2: comefrom ... when (success1 == true && success2 == true);
clean1: comefrom ... when (success1 == true && success2 == false);
- Add an 'indecision' clause, which halts program execution for a random amount of time before proceeding to a random comefrom statement.
- Add a 'googlemaps' clause, which traces out a series of goto/comefrom jumps that will automagically lead to a correct program, as long as you're connected to the Internet. However, if you try to print from a program with a 'googlemaps' clause, it will behave as an 'indecision'.
- Add a 'honey_lets_just_ask_for_directions' clause, which crashes your program while a CowboyCoder jumps in the car, er, computer, takes control, corrupts all variables, and then dumps you at a random comefrom location.