Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Languages with GOTO

Name: suomynonA 2007-07-17 12:49 ID:sJhm9IHJ

Is there a modern programming language which has GOTO function in it? I know basic from a millenia ago and recently learned java, and well I hated OOP, but I could live with it if I had goto.

Name: Anonymous 2007-07-21 1:53 ID:+IScw2W8

>>64

That can be done easily enough with a simple FSM. It isn't exactly "equally efficient" as your code, but is a great deal more readable (at least to me). Here, the process is broken up into discrete steps which are separate from each other. It is easier to think about the process in terms of how to organize the steps in relation to each other, without having to mess about with what line of code each one is on.


char state = 'a';

int stopped = 0;

while(!stopped)
{
    switch(state)
    {
        case 'a':

            do1();

            state = 'b';

            break;

        case 'b':

            if(do2())
            {
                state = 'a';
               
            } else {
               
                state = 'c';
               
            }
            break;

        case 'c':

            if(do3())
            {
                state = 'b';
               
            } else {
               
                state = 'd';
               
            }
            break;

        case 'd':

            if(do4())
            {
                state = 'c';

            } else {
               
                state = 'e';
           
            }
            break;

        case 'e':
           
            if(do5())
            {
                state = 'd';
               
            } else {
               
                // quit
               
                stopped = 1;
               
            }
            break;
       
    }
}



Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List