[swift-evolution] Normalizing operator's types
J. Charles N. MBIADA
jcharles.nmbiada at me.com
Wed Jun 15 14:07:56 CDT 2016
Hi Swift,
Since the "removal" of curried function, I am looking for some elegant ways to work with partial functions (and reduce creation of closure and nested func for the developper).
And now I am asking myself if it's not better to align operator's types to the arrow style instead of using tuple argument style.
For example:
Why Int.multiplyWithOverflow's type is (Int, Int) -> (Int, overflow: Bool) instead of (Int -> Int) -> (Int, overflow: Bool)
When curried function will come back (if it come back, which is a personal hope) that will avoid many refactoring.
I think that, write this : let f:(Int, Int) throws -> Int = (+) seem a bit ugly for this purpose
let f:(Int -> Int) -> Int = (+) seem more suitable.
We could imagine that in the future the compile could automatically create a closure if the programmer define something like
let lmul: (Int) -> (Int) -> (Int) = (*)
and then, doing the habitual stuffs : let mulOfTwo = lmul(2)
Kind regards,
--
jcnm
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160615/877e4b54/attachment.html>
More information about the swift-evolution
mailing list