Eric Hodel wrote:
> On Nov 8, 2006, at 6:40 AM, Trans wrote:
>
> > Had use for this today: #returning is a convenience method you'll find
> > in both Facets and ActiveSupport. Jamis' blogged it the other day:
> >
> > http://weblog.jamisbuck.org/2006/10/27/mining-activesupport-object-
> > returning
> >
> > Any one else think this is worthy of standard Ruby?
>
>  From the blog post:
>
> >> The latter is no shorter than the former, but it reads more
> >> elegantly. It feels more "Rubyish". And there are times that it
> >> can save you a few lines of code, if that's important. (Just scan
> >> the Rails source code for more examples.)
>
> So... it usually doesn't save any lines, it adds typing, it hides the
> object you're returning in the middle of a statement and it is
> significantly more expensive to execute[1].  (Oh, but maybe, in some
> cases, it might save you one or two lines of code.)

Er... that seems a backwards and inconsitant interpretation. How can it
add typing if can save a line or two of code? Moreover it is optional
usage, so use it when it saves you the lines and not otherwise, or if
it simply adds to the readility, and not otherwise. As for "hides the
object you're returning in the middle of a statement", how's that? The
object is stated at the very beginning. It's very readible. It says:
here is the object we will return after doing the following things to
it. Without it you have no idea what the goal is --return statements
could be deeping embedded inside the rest of the code.

Now, I grant you the speed issue sucks --and if that's important, again
you have the option of not using it. But also, if it were built in
perhaps it could be optimized (?)

> No thanks.
>
> I don't think that makes it more rubyish.  Every time I've
> encountered #returning in Rails I've found it decreased the
> readability of the code and uselessly increased the complexity.
> (Wait, now what does this return? oh, yeah, way up there.)

Well, a def can easily get "mucky". #returning can help provide some
structural constraint. Most the time it isn't needed, but on occasion I
find it helps.

Besides that the 'tap' functionality can be very hepful in it's own
right.

T.