Comefrom ******** We don't know where to GOTO if we don't know where we've COME FROM. This linguistic innovation lives up to all expectations. -- `R. Lawrence Clark`_ .. _R. Lawrence Clark: http://www.fortran.com/come_from.html Comefrom is a ludicriously powerful flow-control innovation that obviates the need for those sirens of structured programming, ``if then`` and ``while``. Bare ``comefrom`` statements are eligible for jumps from any blank line, provided they are in a scope visible from the blank line. Comefrom also comes in two varieties, the *qualified* ``comefrom [blockname]`` and *conditional* ``comefrom if [condition]``. A statement may be both qualified and conditional, that is, in the form ``comefrom [blockname] if [condition]``. Multiple comefrom dispatch ========================== One of the first things that people think when they encounter ``comefrom`` is, "What if there is more than one eligible?" [#]_ This is really quite silly, as the same problem happens with the known evil, ``goto``: .. code-block:: basic 10 PRINT "Joe is great" 10 PRINT "Joe is dumb" 20 GOTO 10 Different languages handle this in different ways, but most languages with first-class comefrom support call it an error. [#]_ A runtime error is cowardly evasion! With a few seconds of thought, it becomes obvious that the modern fascination with "pub-sub" frameworks is merely an attempt to shoehorn ``comefrom`` into languages without it. Such attempts are clearly inferior to the first-class support in Cf0x10, but they do illustrate that people have no fundamental problem with multiple comefrom dispatch; it should, therefore, not be an error. .. sidebar:: Buzzword! When nerds say "undecidable," they mean, "bad news." The problem such frameworks all encounter is that programs written with them turn out to be very hard to understand. They've figured out an ordering when multiple handlers react to the same event, but, because they are tacked on after a language is designed, they must determine the order dynamically. In other words, which part responds to what event becomes undecidable. Cf0x10, however, embeds publish-subscribe right in the core of its design, enabling you to determine in lexical scope what parts of the program may respond to an event. It follows a few simple rules: #. Blank lines yield to any ``comefrom`` statement in inverted lexical scope #. When more than one ``comefrom`` is an eligible jump target in a single scope, the last wins, in source-code order #. Execution jumps to the current scope after jumping to eligible ``comefrom`` statements in nested scopes #. Nested-scope ``comefrom`` statements execute depth-first, as seen in source code indentation, where blocks that are first in the source are executed first That's it! With four simple rules, you can see at a glance which code will run upon what condition. .. rubric:: See also - `Datamation article introducing comefrom`_ - `Come from in Intercal`_ - `Origin of comefrom`_, with some interesting info about similar instructions in real languages - `The original Intercal paper`_, which did not use comefrom - `Comefrom0x10 on Esolangs`_ .. _Come from in Intercal: http://catb.org/~esr/intercal/ick.htm#COME-FROM-and-NEXT-FROM .. _Datamation article introducing comefrom: http://www.fortran.com/come_from.html .. _Origin of comefrom: http://www.catb.org/jargon/html/C/COME-FROM.html .. _The original Intercal paper: http://www.muppetlabs.com/~breadbox/intercal/intercal.txt .. _Comefrom0x10 on Esolangs: https://esolangs.org/wiki/Comefrom0x10 ---- .. [#] According a scientific poll of one, yours truly .. [#] What I think it would do in Intercal, if I were actually smart enough to write an Intercal program.