|
|
|
|
|
by theamk
497 days ago
|
|
C++-style stack traces, with stack walking and ELF section analysis, are expensive. Python's stack traces, which also involve reading source files from disk, are expensive as well. But go's do not have to be. A compiler can expand "foo()?" to something like: err := foo(); if err != nil { return err.WithStringContext("foo() in MyFile.go:25"); } The only complexity there is appending a constant pointer to "err", and this only happens in error case that uses "?". Depending on implementation it could be a single word write, if compiler can prove there are no other users of "err". (And if your code is carefully written to be allocation-free and appending a pointer kills that? In this case, you don't have to use "?", put "return err" directly.) |
|