|
|
|
|
|
by ootachi
5206 days ago
|
|
Go has exceptions. They are called panic/recover. This has been explained to you time and time again. You keep posting this exact same comment, complete with the "COME FROM" analogy. Then it gets explained to you that panic/recover are an exception system. Then you ignore it. It's really tiresome. Additionally, people get around the lack of generics in C with macros. Go doesn't have those. |
|
The fact is that while in theory panic/recover are mostly equivalent to exceptions, in practice they are very, very different. Panic is only used in truly extreme situations (like running out of memory) or programmer errors, and you can pretty much write code ignoring it.
Most programs at most will need to call recover() once. Compare this with how exceptions are used in most languages where they are a fundamental aspect of a library's API.
Also the way defer() reliably and cleanly handles cleanup is much more pleasant than exception and 'finally'.
As for C macros, good C programmers have known for a long time that they are best avoided as much as possible.