COMEFROM
Encyclopedia : C : CO : COM : COMEFROM
In computer programming, COMEFROM (or COME FROM) is an obscure control flow structure used in some programming languages, primarily as a joke.
COMEFROM is roughly the opposite of GOTO in that it can take the execution state from any arbitrary point in code to a COMEFROM statement. The point in code where the state transfer happens is usually given as a parameter to COMEFROM. Whether the transfer happens before or after the instruction at the specified transfer point depends on the language used. Depending on the language used, multiple COMEFROMs referencing the same departure point may be invalid, be non-deterministic, be executed in some sort of defined priority, or even induce parallel or otherwise concurrent execution as seen in Threaded Intercal.
COMEFROM was initially seen in lists of joke assembly language instructions (as 'CMFRM') and was elaborated upon in a Datamation article by R. Lawrence Clark in 1973. COMEFROM was eventually implemented in the C-INTERCAL variant of the esoteric programming language INTERCAL along with the even more obscure 'computed COMEFROM'. There was also a proposal for 'assigned COMEFROM' for Fortran.
Practical uses
Although COMEFROM is syntactically and semantically valid, and capable of replacing GOTO in some programs, it is considerably more difficult to visualise in program design and actually implement in a programming language. The most practical known use of a COMEFROM-like structure is as a breakpoint during debugging. One implementation of FORTRAN included it, under the name "AT", as a debugging aid, with dire warnings against using it in production code. In addition, many modern CPUs have hardware support for breakpoints.
Example
The following is an example of a program in a hypothetical BASIC dialect with "COMEFROM" instead of "GOTO". An actual example in INTERCAL would be too difficult to read.
10 COMEFROM 40 20 INPUT "WHAT IS YOUR NAME? "; A$ 30 PRINT "HELLO, "; A$ 40 REMThe program (hypothetically) works by asking the user for their name, then greeting them with the same name, and continuing all over again. The instruction "REM" on line 40 is superfluous — the "COMEFROM" statement on line 10 causes a branch back to that line when execution reaches line 40, regardless of its contents.
See also
- F. X. Reid, an expert on the semantics of COMEFROM.
- Action at a distance
External links
- [COMEFROM Information Page]
- [Datamation Article]
- [Joke Assembler Instruction List Including CMFRM]
- [ActiveState Programmer Network information]
From Wikipedia, the Free Encyclopedia. Original article here. Support Wikipedia by contributing or donating.
All text is available under the terms of the GNU Free Documentation License See Wikipedia Copyrights for details.
