[swift-evolution] [swift-evolution-announce] [Review] SE-0089: Replace protocol<P1, P2> syntax with Any<P1, P2>
Dave Abrahams
dabrahams at apple.com
Tue Jun 7 16:13:42 CDT 2016
on Tue Jun 07 2016, Matthew Johnson <swift-evolution at swift.org> wrote:
>> , but haven't realized
>> that if you step around the type relationships encoded in Self
>> requirements and associated types you end up with types that appear to
>> interoperate but in fact trap at runtime unless used in exactly the
>> right way.
>
> Trap at runtime? How so? Generalized existentials should still be
> type-safe.
There are two choices when you erase static type relationships:
1. Acheive type-safety by trapping at runtime
FloatingPoint(3.0 as Float) + FloatingPoint(3.0 as Double) // trap
2. Don't expose protocol requirements that involve these relationships,
which would prevent the code above from compiling and prevent
FloatingPoint from conforming to itself.
> Or are you talking about the hypothetical types / behaviors people
> think they want when they don’t fully understand what is happening...
I don't know what you mean here. I think generalized existentials will
be nice to have, but I think most people will want them to do something
they can't possibly do.
--
-Dave
More information about the swift-evolution
mailing list