What is Nostr?
mleku
npub1fjq…leku
2024-10-27 18:25:36
in reply to nevent1q…jyuv

mleku on Nostr: yeah, Go has goto, and labels, like modern froms of (not line number label) BASIC ...

yeah, Go has goto, and labels, like modern froms of (not line number label) BASIC

they are very useful for making concise and easy to understand state machines... but they are really bad to use in any other way... generally continue/break statements jumping back to the statement at under the label or jumping to the next statement after the scope below the label (eg for loops, etc)

they are a lot cheaper than storing state on the stack especially when usually, such as parsing encoded data or text, you already have a stack being used for this use case and it complicates it to put returns on top of it when the position of execution is a more elegant way to represent the current state (essentially, in machine terms it's writing to the program counter register, which tells the CPU where to load the next instruction from

it was notoriously abused by BASIC programmers in the olden days in place of if/while/for statements

but they aren't obsolete, just have a very narrow use case
Author Public Key
npub1fjqqy4a93z5zsjwsfxqhc2764kvykfdyttvldkkkdera8dr78vhsmmleku