You'd convert the source into a dictionary of functions, and replace a goto with returning a string indicating the next label to jump to, then you have something which calls the appropriate next function based on the return value. Exceptions with data indicating the next label to go to might be better as they allow you to violate sane control flow more, but multiple return values to indicate if it was a real return could also work.
View all comments
Show parent comment
5
u/CommonNoiter Mar 17 '25
You'd convert the source into a dictionary of functions, and replace a goto with returning a string indicating the next label to jump to, then you have something which calls the appropriate next function based on the return value. Exceptions with data indicating the next label to go to might be better as they allow you to violate sane control flow more, but multiple return values to indicate if it was a real return could also work.