Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
COMEFROM
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Programming language control flow structure}} In [[computer program]]ming, '''COMEFROM''' (or '''COME FROM''') is an obscure [[control flow]] structure used in some [[programming language]]s, originally as a joke. <code>COMEFROM</code> is the inverse of <code>[[GOTO]]</code> in that it can take the execution state from any arbitrary point in code to a <code>COMEFROM</code> statement. The point in code where the state transfer happens is usually given as a [[parameter (computer science)|parameter]] to <code>COMEFROM</code>. 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 <code>COMEFROM</code>s referencing the same departure point may be invalid, be non-deterministic, be executed in some sort of defined priority, or even induce [[parallel computing|parallel]] or otherwise [[concurrent computing|concurrent]] execution as seen in [[INTERCAL|Threaded Intercal]].{{cn|date=September 2019}} A simple example of a "<code>COMEFROM x</code>" statement is a [[label (programming language)|label]] <code>x</code> (which does not need to be physically located anywhere near its corresponding <code>COMEFROM</code>) that acts as a "trap door". When code execution reaches the label, control gets passed to the statement following the <code>COMEFROM</code>. 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;<ref name=":0" /> see [[COMEFROM#PythonGoto|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.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)