4 ms·
I think "with" is a great example of where Python and Ruby differ philosophically. Python uses "with" to very explicitly implement their state manager protocol.
by ef4 14y ago
I think "with" is a great example of where Python and Ruby differ philosophically. Python uses "with" to very explicitly implement their state manager protocol.
Ruby doesn't need "with" because "with" is really just a limited special case of what you can do with blocks.
The Python fans will counter that their less general solution is harder to abuse.
- masklinn 14y ago> The Python fans will counter that their less general solution is harder to abuse. Not sure why anybody would say that, you can plenty abuse `with` if you want to have fun, the only thing you can't do is "dual-use" the block really (grab a context and invoke the block multiple times). And that you could always do with a decorator, if you're going there. The only thing `with` is is less flexible/general. `unwind-protect` or `BlockClosure#ensure:` are probably much better examples of the philosophy opposite python though, I've always found ruby rather half-assed.