4 ms·
So the idea would be to allow currying, but not allow partial application of the currying?
by tunesmith 8y ago
So the idea would be to allow currying, but not allow partial application of the currying?
- philipkglass 8y agoPartial application of functions is fine. Partial functions would be disallowed. Here's a function that is only partial, because it can throw an exception instead of returning a value when b is zero: def divide(a: Int, b: Int): Int = a / b Here's a total function to accomplish the same basic goal: def divide(a: Int, b: Int): Try[Int] = Try(a / b) This function always returns a value of the type it's declared to return.
- tunesmith 8y agoThanks for that clarification. I had googled for "partial function vs currying", which led me to results for "partial function application", which was really about partial application of functions, not partial functions. :-/ I swear, probably 80% of my problems in professional life are from overloaded terms.
- AnimalMuppet 8y agoBy "overloaded", do you mean "having multiple definitions"? Or do you mean "carrying too much weight"? ;-)
- dllthomas 8y ago> Partial functions would be disallowed. Some partial functions would be disallowed, assuming you aren't including an actual totality check (which would exclude all partial functions and some total ones).
- eecc 8y agoCurrying always returns another function (if I’m not mistaken it doesn’t even evaluate anything yet) so it’s another thing and the compiler has a complete understanding of what will happen at runtime. With a partial it won’t be able to do that. The later comment with the Try[] is a great example