|
In computer programming, COMEFROM (or COME FROM) is an obscure control flow structure used in some programming languages, primarily as a joke.
A simple example of a "
History
On 1st April 2004, Richie Hindle published an implementation of both Practical usesAlthough Some elements of aspect-oriented programming have been compared to the COMEFROM statement.[3] ExamplesThe 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 The program (hypothetically) works by asking the user for their name, then greeting them with the same name, and continuing all over again. The instruction "
from goto import comefrom, label comefrom .repeat name = raw_input('what is your name? ') if name: print "Hello",name label .repeat print "Goodbye!" # # Ruby implementation 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] Example 1: INTEGER SOLON, GEAR, 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: 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: 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 In example 1, the values of SOLON, GEAR, and EWELL are examined as they were at the completion of statement 10. The AT statement indicates statement 11. In example 2, all the values of STOCK are displayed when statement 35 is encountered. In 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. Hardware implementationThe SHARC DSP supports a
LCNTR=42;
DO x UNTIL LCE; /* COMEFROM x, unless the loop counter is zero */
F12=F0*F4, F8=F8+F12, F0=dm(I0,M3), F4=pm(I8,M9);
IF NZ dm(I2,M2) = F12;
IF ZF dm(I2,M2) = F1;
x: R2 = R3 + 76; /* the label "x" does not exist in the machine code */
Note that the loop termination condition, here specified as A similar feature exists in Microchip dsPIC's for (unnested) loops provided by the 'DO' assembly instruction. It's interruptible and trivial nesting goes up to one level with an additional 5 levels in software. See also
References
External links |
This article is from Wikipedia. All text is available under the terms of the GNU Free Documentation License.
Mercedes Car
This site monitored by SitePinger.net