Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I wish defer was block-scoped rather than function-scoped; that would solve the "defer in a loop" problem. Right now I just wrap the lot in a function for that, which works and isn't too bad, but meh.

defer is more flexibly and explicit though; I rather like that. It's pretty unclear what exactly that "with" does, what you can and can't use inside "with", you can't "just" run any arbitrary code without creating your own class, and you sometimes end up with 3 or more levels of nested "with"s that could have been one defer.

In short, I don't think there's a clear winner. Both are clunky in some scenarios where the other is easier.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: