Contents
COMEFROM
In computer programming, COMEFROM (or COME FROM) is an obscure control flow structure used in some programming languages, originally as a joke. is the inverse of in that it can take the execution state from any arbitrary point in code to a statement. The point in code where the state transfer happens is usually given as a parameter to. 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 s 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. A simple example of a " " statement is a label (which does not need to be physically located anywhere near its corresponding ) that acts as a "trap door". When code execution reaches the label, control gets passed to the statement following the. This may also be conditional, passing control only if a condition is satisfied, analogous to a GOTO within an IF statement. The primary difference from GOTO is that GOTO only depends on the local structure of the code, while COMEFROM depends on the global structure – a GOTO transfers control when it reaches a line with a GOTO statement, while COMEFROM requires scanning the entire program or scope to see if any COMEFROM statements are in scope for the line, and then verifying if a condition is hit. The effect of this is primarily to make debugging (and understanding the control flow of the program) extremely difficult, since there is no indication near the line or label in question that control will mysteriously jump to another point of the program – one must study the entire program to see if any COMEFROM statements reference that line or label. Debugger hooks can be used to implement a COMEFROM statement, as in the humorous Python goto module; see below. This also can be implemented with the gcc feature "asm goto" as used by the Linux kernel configuration option CONFIG_JUMP_LABEL. A no-op has its location stored, to be replaced by a jump to an executable fragment that at its end returns to the instruction after the no-op.
History
was initially seen in lists of joke assembly language instructions (as 'CMFRM'). It was elaborated upon in a Datamation article by R. Lawrence Clark in 1973, written in response to Edsger Dijkstra's letter Go To Statement Considered Harmful. COMEFROM was eventually implemented in the C-INTERCAL variant of the esoteric programming language INTERCAL along with the even more obscure 'computed '. There were also Fortran proposals for 'assigned ' and a ' ' keyword (to complement the existing ' ' loop). On 1 April 2004, Richie Hindle published an implementation of both and for the Python programming language. Despite being released on April Fools' Day and not being intended for serious use, the syntax is valid and the implementation fully works.
Practical uses
Examples
The following is an example of a program in a hypothetical BASIC dialect with " " instead of " ". This program (hypothetically) works by asking the user for their name, greeting them with the same name, and continuing all over again. The instruction " " on line 40 is simply a NOP (in this case, a REMark or comment) — the " " statement on line 10 causes a branch back to that line when execution reaches line 40, regardless of its contents. A fully runnable example in Python with the joke module installed (which uses debugger hooks to control program execution) looks like this: This is an implementation in Ruby of the Intercal COME FROM statement.
OS/360 Fortran G
The OS/360 Fortran G compiler has a debug packet feature. Its "AT" statement is similar to COMEFROM in that it hands the control flow over to the debug block. Breakpoints in general are similar.
This article is derived from Wikipedia and licensed under CC BY-SA 4.0. View the original article.
Wikipedia® is a registered trademark of the
Wikimedia Foundation, Inc.
Bliptext is not
affiliated with or endorsed by Wikipedia or the
Wikimedia Foundation.