[swift-evolution] [Draft] Abolish IUO type

rintaro ishizaki fs.output at gmail.com
Fri Mar 18 00:05:31 CDT 2016


What will happen to map()/flatMap() on IUO attributed optional values?

let foo: Int! = 42
let bar = (foo as ImplicitlyUnwrappedOptional).map { $0.UInt($0) }


Replacement would be something like this?

let bar: UInt! = (foo as Int?).map { UInt($0) }


I have never seen code like this in real world,
but it should be covered in "Impact on existing code" section.


2016-03-18 13:12 GMT+09:00 Chris Lattner via swift-evolution <
swift-evolution at swift.org>:

>
> > On Mar 17, 2016, at 9:08 PM, Chris Lattner via swift-evolution <
> swift-evolution at swift.org> wrote:
> >
> > On Mar 17, 2016, at 5:50 PM, Brent Royal-Gordon <brent at architechies.com>
> wrote:
> >
> >>> It seems like this unnecessarily complicates the surface model of
> Swift.  To me, it seems like there is no advantage to having two ways to
> spell this.
> >>
> >>   @autounwrapped let foo = functionReturningOptional()
> >>
> >> I *believe* that, without the `@autounwrapped` attribute, there's no
> way to go from T? to T! without actually restating T somewhere.
> >
> > Right, that's part of the feature :-)
>
> Sorry, less snarky answer:
>
> You are right that today it is a regression vs:
>
> let foo : ImplicitlyUnwrappedOptional = ...
>
> However, I have never seen someone actually do that, and if they did, I
> would observe that the T is a lot more illuminating than the ! part of the
> type.  Is there a concrete use case you are concerned about?
>
> -Chris
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160318/912942ef/attachment.html>


More information about the swift-evolution mailing list