#errdefer vs defer, do I need both?
1 messages · Page 1 of 1 (latest)
You don't need both. defer is called at any return site of the enclosing function. errdefer is called if the enclosing function returns an error.
Note, neither will be called in cases like panics, segfaults, or signals. Panics and signals can be caught separately using handlers, which I can elaborate on a little if you're curious.
Well, I am a little curious how those can be handled. I know about root.panic as a panic handler but is there a way to 'survive' a panic with a unwind handler?
you'll probably want to dig deep into the source code, langref recommends:
See std.debug.simple_panic for a basic implementation of this namespace.