COMEFROM

In computer programming, COMEFROM (or COME FROM) is an obscure control flow structure used in some programming languages, originally as a joke. COMEFROM is the inverse 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.[citation needed]

A simple example of a "COMEFROM x" statement is a label x (which does not need to be physically located anywhere near its corresponding COMEFROM) that acts as a "trap door". When code execution reaches the label, control gets passed to the statement following the COMEFROM. 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;[1] 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

COMEFROM 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,[2] 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 COMEFROM'. There were also Fortran proposals[3] for 'assigned COME FROM' and a 'DONT' keyword (to complement the existing 'DO' loop).

On 1 April 2004, Richie Hindle published an implementation of both GOTO and COMEFROM for the Python programming language.[1] 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 "COMEFROM" instead of "GOTO".

10 COMEFROM 40
20 INPUT "WHAT IS YOUR NAME? "; A$
30 PRINT "HELLO, "; A$
40 REM

This program (hypothetically) works by asking the user for their name, greeting them with the same name, and continuing all over again. The instruction "REM" on line 40 is simply a NOP (in this case, a REMark or comment) — the "COMEFROM" 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 goto module installed (which uses debugger hooks to control program execution) looks like this:

from goto import comefrom, label

comefrom .repeat
name = raw_input('What is your name? ')
if name:
    print("Hello", name)
    label .repeat
print("Goodbye!")

This is an implementation in Ruby of the Intercal COME FROM statement.

$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

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.[4]

  • Example 1: the values of SOLON, GFAR, and EWELL are examined as they were at the completion of statement 10. The AT statement indicates statement 11.
      INTEGER SOLON, GFAR, EWELL
         .
         .
         .
10    SOLON = GFAR * SQRT(FLOAT(EWELL))
11    IF (SOLON) 40, 50, 60
         .
         .
         .
      DEBUG UNIT(3)
      AT 11
      DISPLAY GFAR, SOLON, EWELL
      END
  • Example 2: all the values of STOCK are displayed when statement 35 is encountered.
      DIMENSION STOCK(1000),OUT(1000)
         .
         .
         .
      DO 30 I=1, 1000
25    STOCK(I)=STOCK(I) - OUT(I)
30    CONTINUE
35    A = B + C
         .
         .
         .
      DEBUG UNIT(3)
      AT 35
      DISPLAY STOCK
      END
  • Example 3: tracing begins at statement 10, at statement 20, tracing stops while the loop is executed, and resumes after the loop. Tracing stops just before statement 30 is executed.
10    A = 1.5
12    L = 1
15    B = A + 1.5
20    DO 22 I = 1,5
         .
         .
         .
22    CONTINUE
25    C = B + 3.16
30    D = C/2
      STOP
         .
         .
         .
      DEBUG UNIT(3), TRACE
C     DEBUG PACKET NUMBER 1
      AT 10
      TRACE ON
C     DEBUG PACKET NUMBER 2
      AT 20
      TRACE OFF
      DO 35 I = 1,3
         .
         .
         .
35    CONTINUE
      TRACE ON
C     DEBUG PACKET NUMBER 3
      AT 30
      TRACE OFF
      END

See also

Serious programming contrivances involving ideas resembling COMEFROM:

References

  1. ^ a b Hindle, Richie (1 April 2004), goto for Python, Entrian.
  2. ^ Clarke, Lawrence, "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.", Datamation (article), archived from the original on 2018-07-16, retrieved 2004-09-24.
  3. ^ Modell, Howard; Slater, William (April 1978). "Structured programming considered harmful". ACM SIGPLAN Notices. 13 (4): 76–79. doi:10.1145/953411.953418. Retrieved 18 July 2014.
  4. ^ IBM System/360 and System/370 Fortran IV Language, GC28-6515-10, May 1974
  5. ^ F. X. Reid, On the Formal Semantics of the COMEFROM Statement. FACS FACTS, Issue 2006-1, pages 18–20, March 2006.

Read other articles:

Windmill in the Netherlands Kingmatille, DronrypKingmatille, December 2008OriginMill nameKingmatilleMill locationKeimptilsterdyk 12a, 9035 VL DronrypCoordinates53°11′07″N 5°36′58″E / 53.18528°N 5.61611°E / 53.18528; 5.61611Operator(s)Stichting Molens in MenameradielYear built1985InformationPurposeDrainage millTypeSmock millStoreysThree-storey smockBase storeysOne-storey baseSmock sidesEight sidesNo. of sailsFour sailsType of sailsCommon sailsWindshaftCast i...

 

ذئبة حمامية قرصية آفات الذئبة الحمامية القرصية على الوجه.آفات الذئبة الحمامية القرصية على الوجه. معلومات عامة الاختصاص طب الجلد  من أنواع ذئبة حمامية  تعديل مصدري - تعديل   تمثل الذئبة الحمامية القرصية الشكل الأشيع من الذئبة الجلدية المزمنة، وهي مرض مناعي ذاتي يصيب...

 

Darren Barr Datos personalesNacimiento Glasgow, Escocia17 de marzo de 1985Nacionalidad(es) Altura 1.80 metrosCarrera deportivaDeporte FútbolClub profesionalDebut deportivo 2004(Falkirk FC)Club Dumbarton FCLiga Scottish ChampionshipPosición DefensaSelección nacionalPart. 1[editar datos en Wikidata] Darren Barr (Glasgow, Escocia, 17 de marzo de 1985), futbolista escocés. Juega de defensa y su actual equipo es el Kilmarnock FC de la Scottish Championship de Escocia. Selección naci...

Bantu native to Buganda, Uganda BagandaBaganda traditional danceTotal population5,555,319[1][2]Regions with significant populations UgandaLanguagesLuganda, EnglishReligionChristianity, African Traditional Religion, IslamRelated ethnic groupsBasoga, Bagwere and other Bantu peoples GandaPersonOmuGandaPeopleAbaGandaLanguageOluGandaCountryBuGanda The Baganda[3] (endonym: Baganda; singular Muganda) also called Waganda, are a Bantu ethnic group native to Buganda, a subn...

 

Historic house museum This article uses bare URLs, which are uninformative and vulnerable to link rot. Please consider converting them to full citations to ensure the article remains verifiable and maintains a consistent citation style. Several templates and tools are available to assist in formatting, such as reFill (documentation) and Citation bot (documentation). (August 2022) (Learn how and when to remove this template message) class=notpageimage| Charleston Farmhouse shown within East Su...

 

Список творів, які написав Григорій Сковорода та перелік науково-творчих робіт про нього. Зміст 1 Перелік творів 1.1 Поезії 1.2 Байки Харківські 1.3 Трактати, діалоги, притчі 1.4 Переклади 1.5 Інше 2 Рукописи та оригінали 3 Видання творів 3.1 18-19 століття 3.2 20 століття 3.3 21 століття 4 ...

1986 film by Donald Brittain The ChampionsGenreDocumentaryDirected byDonald BrittainCountry of originCanadaOriginal languageEnglishNo. of episodes3Original releaseNetworkCBC TelevisionRelease1978 (1978) –1986 (1986) The Champions is a three-part Canadian documentary mini-series on lives of Canadian political titans and adversaries Pierre Elliott Trudeau and René Lévesque. Directed by Donald Brittain and co-produced by the National Film Board of Canada and the Canadian Broad...

 

American rapper and singer (born 1982) Dwayne Carter redirects here. For the racecar driver, see Duane Carter. Weezy redirects here. Not to be confused with Wheezy. Lil WayneLil Wayne in 2020BornDwayne Michael Carter Jr. (1982-09-27) September 27, 1982 (age 41)New Orleans, Louisiana, U.S.Other names Weezy Weezy F. Baby Tunechi President Carter EducationUniversity of PhoenixOccupations Rapper singer songwriter record executive entrepreneur Years active1995–presentWorksAlbumssi...

 

In addition to the variety of verified DNA structures, there have been a range of proposed DNA models that have either been disproven, or lack evidence. Some of these structures were proposed during the 1950s before the structure of the double helix was solved, most famously by Linus Pauling. Non-helical or side-by-side models of DNA were proposed in the 1970s to address what appeared at the time to be problems with the topology of circular DNA chromosomes during replication (subsequently res...

Nuraghe ArrubiuNuraghe ArrubiuShown within SardiniaLocationOrroli, Sardinia, ItalyTypeSettlementHistoryPeriodsBronze AgeCulturesNuragic civilization The Nuraghe Arrubiu is one of the largest nuraghes in Sardinia. It is in Orroli, in the province of South Sardinia. Its name means red nuraghe in the Sardinian language, which derives from the basalt stones it had been built with.[1] The structure was built during the fifteenth century BC; the main tower originally reached a height of bet...

 

Place in Styria, SloveniaGovceGovceLocation in SloveniaCoordinates: 46°9′19.25″N 15°10′7.32″E / 46.1553472°N 15.1687000°E / 46.1553472; 15.1687000Country SloveniaTraditional regionStyriaStatistical regionSavinjaMunicipalityLaškoArea • Total1.28 km2 (0.49 sq mi)Elevation550.7 m (1,806.8 ft)Population (2002) • Total11[1] Govce (pronounced [ˈɡoːu̯tsɛ]) is a small settlement in the Muni...

 

Katerini StadiumFull name1st Municipal Athletic Center of KateriniFormer namesNational Stadium of KateriniLocationNational Stadium District, Katerini, GreeceCoordinates40°15′41″N 22°30′43″E / 40.26139°N 22.51194°E / 40.26139; 22.51194OwnerMunicipality Of KateriniOperatorPierikos FCExecutive suitesNoCapacity4.995Record attendance12.000 Pierikos F.C. - Aris F.C. (8/2/1970)Field size105 x 68 mSurfaceGrassScoreboardNoConstructionBroke ground1961Built1961 -...

Multi-use stadium in Juba, South Sudan This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: Juba Stadium – news · newspapers · books · scholar · JSTOR (July 2016) (Learn how and when to remove this template message) Juba StadiumFull nameJuba Football StadiumLocationJuba, South SudanCapacity12,000SurfaceGrassOpene...

 

Title in the Peerage of Scotland For the boxing rules, see Marquess of Queensberry Rules. Marquessate of QueensberryArms: Quarterly: 1st & 4th, Argent, a Human's Heart Gules, imperially crowned Or, on a Chief Azure, three Mullets of the field (for Douglas); 2nd & 3rd, Azure, a bend between six Crosses-Crosslet fitchée Or (for Mar); all within a Bordure Or, charged with a Double Tressure flory counterflory Gules (for Scotland). Crest: A Human Heart Gules, imperially crowned proper, wi...

 

Stockwell in 1965 Dean Stockwell was an American actor whose career spanned over 70 years. He began his career as a child actor, performing as a contract player for Metro-Goldwyn-Mayer. In the 1960s, he transitioned into adult roles, appearing in Sons and Lovers (1960) and Rapture (1965), followed by The Dunwich Horror (1970) and Dennis Hopper's The Last Movie (1971). Stockwell had a career revival in the 1980s, appearing in Wim Wenders' acclaimed drama Paris, Texas (1984), followed by roles ...

Texas de BrazilTypePrivateIndustryRestaurantsGenreChurrascariaFoundedOctober 13, 1998; 25 years ago (1998-10-13) in Addison, Texas[1]Headquarters2952 N Stemmons Fwy, Dallas, Texas, United StatesNumber of locationsOver 50 U.S. + InternationalKey peopleSalim Asrawi (President)Websitewww.texasdebrazil.com Texas de Brazil is a family owned churrascaria (Brazilian steakhouse) restaurant chain with locations both internationally and domestically. It debuted October 13, 199...

 

Oto-Manguean of Mexico Not to be confused with Yatzechi Zapotec. Yatzachi ZapotecDižə'əxonPronunciation[diʒəˤˈʐon][1]RegionOaxaca in MexicoNative speakers(2,500 cited 1990 census)[2]Language familyOto-Manguean ZapotecanZapotecSierra NorteZoogochoanYatzachi ZapotecOfficial statusRegulated byInstituto Nacional de Lenguas IndígenasLanguage codesISO 639-3zavGlottologyatz1235Zapotecan languages in Oaxaca. The Yatzachi dialect is found in the Villalteco region....

 

Russian cross-country skier Alexander LegkovAleksandr Legkov at the World Championships 2007 in Sapporo.CountryRussianFull nameAlexander Gennadiyevich LegkovBorn (1983-05-07) 7 May 1983 (age 40)Krasnoarmeysk, Russian SFSR Soviet UnionHeight1.77 m (5 ft 10 in)Ski clubDinamoWorld Cup careerSeasons15 – (2003–2017)Individual wins9Team wins3Indiv. podiums35Team podiums12Indiv. starts212Team starts30Overall titles0 – (2nd in 200...

Hayao Kawabe 川辺駿 Kawabe bermain untuk Grasshopper pada 2021Informasi pribadiTanggal lahir 8 September 1995 (umur 28)Tempat lahir Asakita-ku, Hiroshima, JepangTinggi 178 cm (5 ft 10 in)Posisi bermain Gelandang serangInformasi klubKlub saat ini Grasshopper(dipinjam dari Wolverhampton Wanderers)Nomor 40Karier junior2008–2013 Sanfrecce HiroshimaKarier senior*Tahun Tim Tampil (Gol)2013–2021 Sanfrecce Hiroshima 86 (4)2015–2017 → Júbilo Iwata (pinjaman) 91 (9)2021...

 

This article is an orphan, as no other articles link to it. Please introduce links to this page from related articles; try the Find link tool for suggestions. (August 2016) J.E. Benson Public School (formerly Wyandotte Street School) was an elementary school in Windsor, Ontario, Canada. J.E. Benson School is administered by the Greater Essex County District School Board, which also services sixty-one other elementary schools located in Windsor, Ontario and Essex County, Ontario. History Const...

 

Strategi Solo vs Squad di Free Fire: Cara Menang Mudah!