词条 | COMEFROM |
释义 |
In computer programming, COMEFROM (or COME FROM) is an obscure control flow structure used in some programming languages, originally as a joke. The point in code where the state transfer happens is usually given as a parameter to A simple example of a " 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
GOTO and COMEFROM for the Python programming language.[3] Despite being released on April Fools' Day and not being intended for serious use, the syntax is valid and the implementation fully works.Practical usesExamplesThe following is an example of a program in a hypothetical BASIC dialect with " 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 " A fully runnable example in Python with the joke 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 Some examples of the debug packet feature of the OS/360 Fortran G compiler:[4]
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
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
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 C DEBUG PACKET NUMBER 3 AT 30 TRACE OFF END See also
Serious programming contrivances involving ideas resembling COMEFROM:
References1. ^{{Citation |url= http://www.fortran.com/fortran/come_from.html |last= Clarke |first= Lawrence |authorlink= R. Lawrence Clark |title= 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.|journal= Datamation |type= article}}. 2. ^{{Cite journal |url= http://www.modell.com/Magery/SPharmful.html |last= Modell |first= Howard |last2= Slater |first2= William |title= Structured programming considered harmful |date= April 1978 |journal= ACM SIGPLAN Notices |volume=13 |issue= 4 |pages= 76–79 |doi= 10.1145/953411.953418 |accessdate= 18 July 2014}} 3. ^1 {{Citation|last=Hindle|first=Richie|title=goto for Python|date=1 April 2004|url=http://entrian.com/goto/|contribution=|publisher=Entrian}}. 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. External links
2 : Computer humor|Control flow |
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。