Add GOTO & LABEL
Created by: dvkt
My boss is really getting on my case about the big rewrite of our cryptocurrency platform in LDPL. He says we're not going to be able to move fast and break things if we don't have GOTO
in the language.
I told him most people think GOTO
is more harmful than helpful, and that it's known to be especially dangerous in complicated systems, but he said that he looked up this Dijkstra guy and he wasn't impressed with his Github profile.
So anyway, this patch adds two new keywords to LDPL: GOTO
and LABEL
. They are just piggybacking C++'s goto
, really. Pretty barebones.
They have to both be used together in the same sub-procedure or in the main code body of an LDPL program. So you can't goto
across functions or anything like that.
Here's a little example script to test:
procedure:
GOTO start
LABEL start
display "> starting..." crlf
GOTO ending
LABEL middle
display "> entering the middle section..." crlf
sub-procedure cool-code
GOTO cool
display "hmm... is this cool?" crlf
LABEL cool
LABEL SUBPR_COOL_CODE
display "wow, yeah! cool code!" crlf
end sub-procedure
LABEL ending
CALL cool-code
display "> that's the end" crlf
The output, you can see LABEL middle
and the start of the cool-code
subprocedure are skipped:
> starting...
wow, yeah! cool code!
> that's the end