2 ms·
Ruby blocks are another example of something that looks like a functional programming feature but is actually not. As in Java 8 and C++11, which also added lamb
by zelly 7y ago
Ruby blocks are another example of something that looks like a functional programming feature but is actually not. As in Java 8 and C++11, which also added lambdas, it doesn't have much in common with FP lambdas. These are essentially syntax sugar for an ad-hoc function that's too small to factor our and give a name. FP lambdas are the most elementary unit of computation. You're supposed to be doing absolutely everything with lambdas even addition, theoretically (head in the clouds academic BS), and the other syntax (like `do` in Haskell) is sugar for lambdas.
So basically Ruby is far from FP. It sticks to OOP, which has actually been proven to work.
- pjmlp 7y agoFrom CS point of view, I miss the point you are trying to make. No mainstream FP language is doing pure lambda calculus.
- foldr 7y agoIIRC the main distinguishing feature of ruby blocks from regular anonymous functions is that you can break out of a containing scope from within them.
- uryga 7y ago> [Java 8 and C++11 lambdas] are essentially syntax sugar for an ad-hoc function that's what a lambda is pretty much anywhere, FP or not :) > [in FP] you're supposed to be doing absolutely everything with lambdas even addition in imperative programming, are you supposed to be doing everything by writing symbols to a moving tape, a la Turing? there's more to FP than pure lambda calculus, even if it was the starting point. sure, natural numbers and other types can be implemented with lambdas. no serious FP language actually does that.