2 ms·
> If it was scope based there's nothing you could do to get func_defer behavior. That's clearly false. You could set up a list to hold objects to be disposed (
by pcwalton 9y ago
> If it was scope based there's nothing you could do to get func_defer behavior.
That's clearly false. You could set up a list to hold objects to be disposed (or, more generally, closures to execute) and defer a simple procedure that disposes of all objects in the list. This is in fact what the implementation of defer must do internally.
- ovao 9y agoI think by that he means it wouldn't be possible to get func_defer behavior in the example with a single keyword, or without some form of qualifier. The compiler wouldn't be able to differentiate the behavior.