

Ruby "with statement" - otobrglez
http://blog.mrbrdo.net/2013/02/ruby-with-statement/
How would you implement "with statement"?
======
dragonwriter
Article claims that this implementation provides something like the "Pascal or
Python" with statement. But its nothing like Python's "with" statement
(PEP-343), which is a tool for encapsulating initialization, exception
handling, and cleanup logic, not a tool to avoid identifying the object on
method calls.

It'd be pretty easy to do something like Python's "with" statement as a
library method in Ruby, but this isn't it.

~~~
mrbrdo
Nope, article doesn't claim that. I just said that Python and Pascal have a
with statement, I didn't say here is an implementation of Python's PEP-
whatever in Ruby. And I have no interest or desire to get into language
flamewars. For me this basic functionality is enough.

~~~
dragonwriter
> For me this basic functionality is enough.

Its not about "basic functionality": this does exactly nothing in common with
the function of the Python with statement.

What you provide gives very similar functionality to the "with" statement in
Pascal or Visual Basic, but, aside from the name, has nothing _whatsoever_ in
common with the "with" statement in Python (which itself has more in common
with Ruby's new-with-block idiom for opening, using, and closing a resource
than with the Pascal/VB use of "with" as shorthand for object-member-access-
within-a-delimited block.)

If you didn't know what Python's with statement _does_ , you probably
shouldn't have mentioned it at all in reference to what you are providing for
Ruby.

