[swift-evolution] Default Generic Arguments
Anton Zhilin
antonyzhilin at gmail.com
Fri Jan 27 15:43:15 CST 2017
Current alternative to default generic arguments is typealias, like
basic_string and string in C++:
struct BasicBigInt<T> { ... }
typealias BigInt = BasicBigInt<Int64>
It’s not *that* ugly. It keeps type inference rules simpler, easier to
understand and more explicit.
As someone noted, current type inference for generic initializers works
satisfactory in 99% cases. Is it really worth it to try to cover 99.9% at
the cost of complexity of type inference rules?
On the other hand, in the wild, there may exist types with 3 or even more
generic parameters that have sensible default values. [Research needed]
For such complex cases, I think, it makes sense to add default generic
parameters *only* together with generic parameter labels.
Also, in such cases, functions on types could often help. And that story is
even out of scope of Swift 4 Phase 2.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170128/53e781ee/attachment.html>
More information about the swift-evolution
mailing list