by f1shy · 3y ago · 0 comments
Dijkstra didn't understand that GOTO is equivalent to tail recursion. The way you untangle the spaghetti of a GOTO graph with shared variables is to divide it into basic blocks, and turn them into pure tail-calling functions. The assignments to shared variables become argument passing. From there you might be able to identify some meaning in those functions.
The GOTO is also a fundamental block in that you can use conditionals and goto as a target language for higher level constructs --- and this is clear and efficient.
Semaphore API calls are a horrible target language for implementing other synchronization primitives. They are too encapsulated: each semaphore is a tiny mutex protecting only a counter. So then you face an abstraction inversion right away: to protect anything else, you're using a tiny mutex which protects a counter, plus that counter, as a bigger mutex.
I currently work in a codebase which carries its won semaphore, which is used a lot. The implementation is a POSIX mutex, condition variable and counter! Ouch, that hurts. It's more regressive than a tax that takes money from single moms to give a corporation a break.
Dangerous?
Proven to be?
The time has shown that anti goto cult was huge overreaction that gained size due to decades long brain washing by academics on inexperienced programming practicioners (students)
Goto in newer languages is not bad and exceptions which arent as criticized are way more powerful in goto-like sense
Original gotos from that infamous paper were more powerful
can you clarify that please.
> and exceptions which arent as criticized are way more powerful in goto-like sense
They are less general therefore less powerful, and by that, less capable of being abused.
Youre limited by scope, and since we do not write imperative code nowadays everywhere then it is enough to make significant difference