ara.t.howard wrote:
>> Introducing needless temporaries on the same scope level as the target
>> variable makes understanding and maintenance harder.  Look again:
>>
>>    all_files = stems.map { |f|
>>       f + "." + guess_extension(f)
>>    }.as { |t|
>>       transform2(source_files + transform1(t))
>>    }.map { |f|
>>       File.join(dir, f)
>>    }
> 
> the very real problem with this sort of thing is that exceptions will 
> map to one fugly line, making debugging for some poor soul a nightmare.  

That's just false. The backtrace will have the correct line number, no 
matter how many lines an expression spans.

> and of course this isn't even addressing the issue that anyone *really* 
> naming a function transform1 or transform2 should be smothered in their 
> sleep

+1, no one will argue with that, but it's unrelated to the issue at 
hand. If your purpose was to poison the well[1] by pouring ridicule on a 
tangential topic, shame on you. If not, I apologize.

> i strongly disagree: variable names are one of the single most important 
> elements of writing maintainable code - unless you happen to be one of 
> the very few who loves writing documentation (i certainly don't).  
> variables being references in ruby, i consider it something almost evil 
> *not* to through in a well named variable where it lends clarity by 
> literally spelling out the programmer's intent, cuts line length, makes 
> transitioning or modifying the code later vastly easier, and stacktraces 
> actually meaningful

Well it's a good thing that you like variable names because Object#as is 
*all* about using variables. So let's rewrite the example to use 
*descriptive* variables names (and less lines, you seem to like less lines):

     all_files = stems.
       map{ |stem| stem + "." + guess_extension(stem) }.
       as{ |guesses| transform2(source_files + transform1(guesses)) }.
       map{ |basename| File.join(dir, basename) }

In the end, this is not a question of golfing or clarity or 
maintainability or bad programming practices. It's simply a question of 
style: imperative vs. functional. The only objective difference is that 
using Object#as the temporary variable you create is isolated within its 
own scope. The rest is an entirely subjective difference of style.

Daniel

[1] http://www.nizkor.org/features/fallacies/poisoning-the-well.html