▲ | __s 4 days ago | |
1. it avoids a level of indentation until you wrap it in a function 2. mechanic is tied to call stack / stack unwinding 3. it feels natural when you're coming from C with `goto fail` (yes it annoys me when I want to defer in a loop & now that loop body needs to be a function) | ||
▲ | torginus 3 days ago | parent [-] | |
I think you hit the nail on the head - I think it's the stupid decision on Go lang designers part to make panic-s recover-able. This necessitates stack unwinding, meaning defer-s still need to run if a panic happens down the stack. Since they didn't want to have a 'proper' RAII unwinding mechanism, this is the crappy compromise they came up with. |