On Nov 15, 2006, at 2:50 PM, Trans wrote:
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?
Most of the time it adds code. Look at the two examples on the blog
post. In the returning case I add “returning do || end” in the
simple case I have an extra “=”.
The example shows in the blog post shows returning saving exactly 0
lines of code. It claims that in some cases it saves lines, but
doesn’t give any examples, so it is probably a very rare statement.
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.
If it commonly saved lines then I’d expect the blog post would have
used such an example. I doubt that it commonly saves lines (the blog
post implies it usually does nothing to the line count).
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.
In most every other place in ruby the last line of a code grouping
construct is the return value. This is the way I’ve been reading my
Ruby for years. With #returning the return value is buried in the
middle of the line between “returning” and “do”.
It’s very readible. It says: here is the object we will return
after doing the following things to it.
That’s extra state I have to keep in my brain to keep the code straight.
Traditional code doesn’t require me to hold extra state in my head
because its linear. Linear is simpler and simpler is more readable.
Without it you have no idea what the goal is --return statements
could be deeping embedded inside the rest of the code.
This statement is orthogonal to the use of #returning. You may throw
in extra returns anywhere you like regardless of the #returning block.
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 (?)
Its simpler to just not have it at all. #returning gives no great
benefit and has many downsides.
find it helps.
#returning isn’t going to add any structure since it doesn’t really
do anything. You’re really just replacing ‘var’ with ‘end’ and
adding a bunch of whitespace.
Besides that the ‘tap’ functionality can be very hepful in it’s own
right.
So what? I didn’t mention #tap in my email.
–
Eric H. - [email protected] - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant
http://trackmap.robotcoop.com