Goto Come From Pair

An attempt at alleviating the dangers of Goto (GotoConsideredHarmful) and ComeFrom (InterCal), by combining the two into something a little more strict. The basic concept is that each GoTo and ComeFrom 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

Example:
 void someFunc()
 {
   T *X1, *X2;
   ...
   X1 = (T*)malloc(...);
   ...
   if (FAILED(func1())
 func1_failed: goto clean1;
   ...
   X2 = (T*)malloc(...);
   ...
   if (FAILED(func2())
 func2_failed: goto clean2;
   ...
 clean2: comefrom func2_failed, func3_failed, ...;
   free(X2);
 clean1: comefrom func1_failed, funcX_failed, ...;
   free(X1);
 }

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:

 clean2: comefrom ... when (success1 == true && success2 == true);
 clean1: comefrom ... when (success1 == true && success2 == false);

CategoryBranchingAndFlow

EditText of this page (last edited January 10, 2014) or FindPage with title or text search