Ville Vainio wrote:
>>>>>>"Hal" == Hal Fulton <hal9000 / hypermetrics.com> writes:
> 
> 
>     Hal> I'd have thought t.split.join(' ') would better exemplify
>     Hal> both OO and FP.
> 
> ' '.join(sequence) tends to get some bad rep, but I think it's more OO
> of the two. After all, general sequences should not have an operation
> of "join elements with strings", because it doesn't make sense for
> e.g. a sequence of sockets, while for a string it's reasonable to
> provide an operation that joins a sequence of string with itself
> (because it can expect the sequence to be that of strings).
> 
> That is, string can know about sequences, but a sequence, being a more
> general data type, should not know about strings.

I'd have to disagree. join, since it produces a string, obviously
knows about strings even though it is not a string method.

As for x.y, I think it general we are "performing operation y on
object x" -- and it seems clear to me that join is NOT acting on
' ' (which is only a single item anyway).

> As far as FP goes, allowing t.split w/o () is extremely non-FP,
> because you lose first class functions. And FP without first class
> functions is, well, Java.
> 

I don't know FP either, but I thought method chaining was an important
part of it. Because of the disconnect I mentioned earlier (where join
is not actually acting on its receiver), the previous example doesn't
show true method chaining.

As for the parens: I've never missed first class functions in Ruby.
Maybe I should. But I prefer the uniform access principle if I have to
choose between that and fcf.

Let's channel this discussion more productively: Why should I want
first-class functions? Honest question, no sarcasm.


Hal