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

Fwiw, I've been using `using` for the last year or so maybe, and I've found exactly one case where I've wanted to create a new explicit scope for the resource. In all other cases, having the resource live as long as the containing function/loop/whatever was the clearest option, and being forced to create a new scope would have made my code messier, more verbose, and more indented.

Especially as in the one case where it was useful to create an explicit scope, I could do that with regular blocks, something like

    console.log("before")
    {
      using resource = foo()
      console.log("during", resource) 
    }
    console.log("after")
Having used Python's `with` blocks a lot, I've found I much prefer Javascript's approach of not creating a separate scope and instead using the existing scoping mechanisms.


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

Search: