On 15.11.2007 05:26, ara.t.howard wrote:
> On Nov 14, 2007, at 8:57 PM, Daniel DeLorme wrote:
> 
>> But you can *always* refactor code to fit a particular style. FC  
>> wants to talk about the usefulness of Object#as in functional-style  
>> code and Robert insists that Object#as is not needed in imperative  
>> code. We clearly have a cultural barrier with the 2 sides talking  
>> past each other.
> 
> this seems pretty close to the mark.  i realized that, for me, #as  
> seems a bit too functional but, as i mentioned, i just need to use it  
> a bit to decide.

Interesting point although I am not sure whether #as is really 
functional (and thus, whether Daniel's remark is really close to the 
mark).  If I think of functional programming paradigm first item that 
comes to mind is lack of side effects (other than IO probably).  Here, 
#as just enables method chaining in a single statement where you would 
otherwise need multiple statements.  From my point of view this is not 
functional vs. non functional.  In the end it's mainly a question of 
scoping: whether you need multiple local variables in the current scope 
or can achieve the same with temporaries in nested and thus smaller 
scopes.  FC has stressed this point several times.

IMHO the (or at least: my) discussion was about the point that FC 
claimed his solution with #as to be more readable than another solution 
that used local variables for temporary values.  So I tried to come up 
with solutions that *I* consider more readable to be able to contrast 
them with his approach.  Note that I do not expect everybody to find 
them equally readable since this is subject to personal preference and 
habit.

Here is another approach that completely gets rid of temporaries without 
needing #as:

all_files =
   add_suffixes(source_files +
	       add_prefixes(
		 stems.map { |stem| "#{stem}.#{guess_extension stem}" }
)).map { |basename|
   File.join dir, basename
}

If anything this seems more functional to me, since you have to read 
inside out. :-)  SCNR

Cheers

	robert