Re:The Last Hope for Scala's Infinity War [video]
by tunesmith on Wednesday July 11, 2018 @06:36PM
(#17510797)
So the idea would be to allow currying, but not allow partial application of the currying?
[ Parent
| on HN ]
Re:The Last Hope for Scala's Infinity War [video]
by philipkglass on Wednesday July 11, 2018 @06:47PM
(#17510840)
Partial 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.
Re:The Last Hope for Scala's Infinity War [video]
by tunesmith on Wednesday July 11, 2018 @07:31PM
(#17511067)
Thanks 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.
Re:The Last Hope for Scala's Infinity War [video]
by AnimalMuppet on Wednesday July 11, 2018 @08:10PM
(#17511239)
By "overloaded", do you mean "having multiple definitions"? Or do you mean "carrying too much weight"?
;-)
Re:The Last Hope for Scala's Infinity War [video]
by dllthomas on Thursday July 12, 2018 @12:18PM
(#17516046)
> 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).
Re:The Last Hope for Scala's Infinity War [video]
by eecc on Thursday July 12, 2018 @02:09AM
(#17512519)
Currying 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