> On Oct 13, 2016, at 3:31 PM, Rick Mann via swift-users
> <firstname.lastname@example.org> wrote:
> Would it make sense to be able to specify priority for a set of overloaded
> methods to help resolve ambiguity?
This might be pretty useful in some situations, but I am not sure if the
semantic complexity that it introduces is worth it.
Another example of how this could be useful:
I made a bare-bones rational number type
<https://gist.github.com/hooman/6e08c48e1e06ee19e06e5b09f664f9be> for Swift a
while ago. I would love to be able to overload “/“ operator to create fractions
(rational numbers) instead of dividing two integers.
If I overloaded “/“ to return rational (Int / Int -> Rational), the result type
of the operator would become ambiguous for every use of it with integer
operands. It would be nice if I could prioritize my overload of “/“ over stdlib
definition to resolve the ambiguity.
swift-users mailing list