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!
===Examples=== The following is an example of a program in a hypothetical [[BASIC programming language|BASIC]] dialect with "<code>COMEFROM</code>" instead of "<code>GOTO</code>". <syntaxhighlight lang="qbasic"> 10 COMEFROM 40 20 INPUT "WHAT IS YOUR NAME? "; A$ 30 PRINT "HELLO, "; A$ 40 REM </syntaxhighlight> This program (hypothetically) works by asking the user for their name, greeting them with the same name, and continuing all over again. The instruction "<code>REM</code>" on line 40 is simply a [[NOP (code)|NOP]] (in this case, a REMark or [[Comment (computer programming)|comment]]) β the "<code>COMEFROM</code>" 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 <code>'''goto'''</code> module installed (which uses debugger hooks to control program execution) looks like this: <syntaxhighlight lang="python"> from goto import comefrom, label comefrom .repeat name = raw_input("What is your name? ") if name: print("Hello", name) label .repeat print("Goodbye!") </syntaxhighlight> This is an implementation in [[Ruby (programming language)|Ruby]] of the Intercal COME FROM statement. <syntaxhighlight lang="ruby"> $come_from_labels = {} def label(l) if $come_from_labels[l] $come_from_labels[l].call end end def come_from(l) callcc do |block| $come_from_labels[l] = block end end </syntaxhighlight>
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)