|
|
|
|
|
by dwattttt
265 days ago
|
|
You mandate it like you mandate anything else in C. You don't. You pick C because you want a language that doesn't require a variable to be initialised before mutably referencing it, and you write your defer statements or "destructors" defensively, expecting that a variable could be in any state when it comes time to dispose of it. Or if you find that unacceptable, you accept that C isn't the language you want. There's many other choices available. |
|
Whereas it's perfectly possible to only defer a statement when you know the "object" has been properly initialized.
That's why defer makes sense in a language like C (even Go), but RAII does not.