Hacker News new | ask | show | jobs
by _dain_ 905 days ago
Because it doesn't have to be something you'd ordinarily think of as a "destructor". e.g. you might have multiple possible functions that consume the value, because you're modelling a state machine with several outgoing edges from the type-state. You get to choose the one you call.
1 comments

`defer` allows for executing arbitrary expressions based on scope (the "destructor" called depends on the code path)