News for hackers. Stuff that matters.
Re:Implementing Go's defer keyword in C++ by masklinn on Sunday October 22, 2017 @06:49AM (#15526122)
> But how does that close over other locals?

It does not, it works like a C++ destructor, the context management code is static, and anything it needs is provided as a parameter.

While "ad-hoc" context managers are possible (and quite trivial in fact):

1. I don't remember ever wanting one

2. they would not be convenient owing to Python's limited lambdas so

3. you'd probably implement them using a ~decorator on a nested function instead which

4. may look quite odd to most Python developers

There are no comments on this comment yet.