18 ms·
I agree the analogy is loose, but your comment raises an interesting question. It seems like we're talking about talking about two different definitions of what
by joelg 10y ago
I agree the analogy is loose, but your comment raises an interesting question. It seems like we're talking about talking about two different definitions of what FP is.
There's a strict, technical definition of "functions which have no side effects", which defines a coding style. But there's also a more subtle, ambiguous definition of "functions as the primary and most irreducible building block of code", which defines a coding philosophy. In my opinion, FP is the latter, so I'd actually disagree and say that your Scala code isn't FP, since it emphasizes transformations on an object.
Maybe I'm in the minority here.
- runT1ME 10y agothe term 'function' refers to a true function, no side effects. So, when I say "FP", that's what I mean. >so I'd actually disagree and say that your Scala code isn't FP, since it emphasizes transformations on an object. What I wrote is no different than change(oldData) |> map(x => x+1) |> filter(x => isTrue(x) Often the '.' style in scala is literally syntactic sugar that will get rewritten to pass the data to a stand alone function.