<div dir="ltr"><div>What will happen to <font face="monospace, monospace">map()/flatMap()</font> on IUO attributed optional values?</div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><font face="monospace, monospace">let foo: Int! = 42</font></div><div><font face="monospace, monospace">let bar = (foo as ImplicitlyUnwrappedOptional).map { $0.UInt($0) }</font></div></blockquote><font face="monospace, monospace"><br></font>Replacement would be something like this?<div><br><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><font face="monospace, monospace">let bar: UInt! = (foo as Int?).map { UInt($0) }</font></blockquote><br>I have never seen code like this in real world,<br>but it should be covered in &quot;Impact on existing code&quot; section.</div><div><font face="monospace, monospace"><br></font></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-03-18 13:12 GMT+09:00 Chris Lattner via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
&gt; On Mar 17, 2016, at 9:08 PM, Chris Lattner via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt;<br>
&gt; On Mar 17, 2016, at 5:50 PM, Brent Royal-Gordon &lt;<a href="mailto:brent@architechies.com">brent@architechies.com</a>&gt; wrote:<br>
&gt;<br>
&gt;&gt;&gt; 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.<br>
&gt;&gt;<br>
&gt;&gt;   @autounwrapped let foo = functionReturningOptional()<br>
&gt;&gt;<br>
&gt;&gt; I *believe* that, without the `@autounwrapped` attribute, there&#39;s no way to go from T? to T! without actually restating T somewhere.<br>
&gt;<br>
&gt; Right, that&#39;s part of the feature :-)<br>
<br>
</span>Sorry, less snarky answer:<br>
<br>
You are right that today it is a regression vs:<br>
<br>
let foo : ImplicitlyUnwrappedOptional = ...<br>
<br>
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?<br>
<div class="HOEnZb"><div class="h5"><br>
-Chris<br>
<br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</div></div></blockquote></div><br></div>