[swift-evolution] [Pitch] Revamp Optional and Throws

David Sweeris davesweeris at mac.com
Sun Apr 30 17:29:11 CDT 2017


> On Apr 30, 2017, at 15:13, Gor Gyolchanyan <gor at gyolchanyan.com> wrote:
> 
> So, what you’re saying is essentially equivalent to replacing Optional struct with an Optional protocol with a default AnyOptional struct implementation, right?
I suppose something semantically identical could be implemented that way, but...

> Having the bulk of compiler magic moved to a protocol was one of my proposed solutions, but it still isn’t optimal due to associated types and need for existential containers, that could seriously slow down the code, considering the heavy use of Optional.
That's the point of doing it through extending the generics system: there's no existential types to pass around because `Optional` is still a concrete type. It'll probably take the compiler a few more cycles to work out exactly what the concrete type is, but I don't think there'd be any more run-time overhead.

At least I *think* it works that way... maybe not, though.

- Dave Sweeris 


More information about the swift-evolution mailing list