In defense of GOTO and GOSUB

new topic     » topic index » view thread      » older message » newer message

I have always felt that the rejection of the GOTO and GOSUB was at best illogical and uncalled for. Here are some reasons:

In all Assemblers I have come across the altering of program flow is a built in function.
You have Assembler instructions such as
JMP - an unconditional GOTO
JZ or JPZ - GOTO if zero flag set
JC or JPC - GOTO if carry flag set
and many more.

You have Assembler instructions such as
CALL - an unconditional GOSUB
CALLZ - GOSUB if zero flag set
CALLC - GOSUB if carry flag set
and many more.

In fact, in Assembler this is very often used in large projects.
To complicate matters in Assembler, a lot of programming is done using the STACK for passing values to the called program, jeopardizing the RETURN location if one is not careful in the called program. In my work, I never used the stack for passing values, thus avoiding the disaster of going to wrong location at RETURN. However, I see that in the current use of Assembler, use of STACK to pass values is not only the norm but actually encouraged.

How does this apply to Euphoria?
Euphoria has rejected GOTO AND GOSUB.
However, CALL BACKs are used. I came across this article which essentially says:
"Callbacks are the modern GOTO"
"Just like goto, these callbacks force you to jump around your codebase in a way that is really hard to understand. You basically have to read the whole program to understand what any individual function does."

For the full article GOTO http://elm-lang.org/learn/Escape-from-Callback-Hell.elm

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu