<div dir="ltr">I think you’re mistaking the scope of the proposal. It’s simply removing IUOs in <i>function signatures</i>, not throughout the language.</div><br><div class="gmail_quote"><div dir="ltr">On Mon, Jun 27, 2016 at 11:31 AM Charlie Monroe via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">There are many useful cases for IUO in Swift - mostly when you have variables that cannot be calculated at the point of calling super.init(), but are guaranteed to be filled during initialization - i.e. during the lifetime of the object, the value is nonnil, but may be nil for a short period of time.<br>
<br>
Or @IBOutlets. Making all @IBOutlets optionals would make the code either riddled with ! or shadowed locally re-declared instance members.<br>
<br>
<br>
&gt; On Jun 27, 2016, at 8:12 PM, Jean-Daniel Dupas &lt;<a href="mailto:mailing@xenonium.com" target="_blank">mailing@xenonium.com</a>&gt; wrote:<br>
&gt;<br>
&gt; Maybe we can prohibit it in Swift function declaration, and allow it only when importing native code.<br>
&gt;<br>
&gt; As David, I don’t see any compelling reason to allow such construct in Swift.<br>
&gt;<br>
&gt;&gt; Le 27 juin 2016 à 10:39, Charlie Monroe via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; a écrit :<br>
&gt;&gt;<br>
&gt;&gt; When you import ObjC code that has no nullability annotation, IUO make sense since:<br>
&gt;&gt;<br>
&gt;&gt; - they can be checked against nil<br>
&gt;&gt; - typically, most values in APIs are nonnull (looking at Foundation, for example, which is why Apple has the NS_ASSUME_NONNULL_BEGIN to mark entire regions as nonnull, yet there is no NS_ASSUME_NULL_BEGIN)<br>
&gt;&gt;<br>
&gt;&gt; Importing them as optionals would make it really hard to work with the code - whenever you get a value, it&#39;s an optional, even in cases where it makes no sense and adding ! to unwrap the optional is not a great solution. And the other solution is to use guards everywhere.<br>
&gt;&gt;<br>
&gt;&gt; IMHO the IUO is a nice (temporary) solution for using un-annotated code until it is. But the &quot;pressure&quot; should be applied on the ObjC code.<br>
&gt;&gt;<br>
&gt;&gt;&gt; On Jun 27, 2016, at 10:03 AM, David Rönnqvist &lt;<a href="mailto:david.ronnqvist@gmail.com" target="_blank">david.ronnqvist@gmail.com</a>&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I don’t know about the chances of getting approved, but I think this is something worth discussing.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; It might just be my ignorance, but I can’t think of a good reason why a function argument would be force unwrapped. Either it’s non-null and the caller is expected to unwrap it or it’s nullable and the method is expected to handle the nil value. So I’m positive to that part of the proposal.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; As to what we should do with the generated interfaces of Objective-C code that hasn’t been annotated with nullability, I think that needs input from more people to find the preferred solution.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Once that’s been discussed some more, I’d be willing to write up a formal proposal if you don’t feel like it (assuming the discussion leads somewhere).<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; - David<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; On 27 Jun 2016, at 06:28, Charlie Monroe via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; See <a href="https://github.com/apple/swift-evolution/blob/master/process.md" rel="noreferrer" target="_blank">https://github.com/apple/swift-evolution/blob/master/process.md</a> - you would need to make an official proposal and submit it as pull request. But given the reaction here, it&#39;s unlikely to get approved.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Also, the ObjC code without nullability is getting fairly rare - all Apple&#39;s frameworks are with nullability information (as far as I&#39;ve checked) in macOS 10.12, iOS 10. Third party libraries should be updated to use nullability (and most libraries that are maintained already do).<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; On Jun 25, 2016, at 5:13 PM, Spromicky via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; So, its proposal is dead, or what we must to do to force it to swift-evolution repo on GitHub?<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; Hello, everyone!<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; I wanna propose to you to remove force unwrapping in fuction signature for swift code. That no sense in clear swift code. If we wanna use some optional value as function param, that is not optional, we must unwrap it before function call.<br>
&gt;&gt;&gt;&gt;&gt;&gt; People who new in swift look at how they old Obj-C code (without nullability modifiers) translate in to swift:<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; Obj-C:<br>
&gt;&gt;&gt;&gt;&gt;&gt; - (void)foo:(NSInteger)bar {<br>
&gt;&gt;&gt;&gt;&gt;&gt; //...<br>
&gt;&gt;&gt;&gt;&gt;&gt; }<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; Swift transaliton:<br>
&gt;&gt;&gt;&gt;&gt;&gt; func foo(bar: Int!) {<br>
&gt;&gt;&gt;&gt;&gt;&gt; //...<br>
&gt;&gt;&gt;&gt;&gt;&gt; }<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; And think that force unwrapping in signature is good practice. And start write functions in clear swift code like this:<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; func newFoo(bar: Int!) {<br>
&gt;&gt;&gt;&gt;&gt;&gt; //...<br>
&gt;&gt;&gt;&gt;&gt;&gt; }<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; and use it like this:<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; let bar: Int? = 1<br>
&gt;&gt;&gt;&gt;&gt;&gt; newFoo(bar)<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; And it really work, and they does not think that this can crash in case if `bar` will be `nil`.<br>
&gt;&gt;&gt;&gt;&gt;&gt; But in clear swift we wanna work with parametrs in function that clearly or optional, or not.<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; func newFoo(bar: Int) {<br>
&gt;&gt;&gt;&gt;&gt;&gt; //...<br>
&gt;&gt;&gt;&gt;&gt;&gt; }<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; or<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; func newFoo(bar: Int?) {<br>
&gt;&gt;&gt;&gt;&gt;&gt; //...<br>
&gt;&gt;&gt;&gt;&gt;&gt; }<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; When we write a new function we know what we need in this case and use optional params or not.<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; So my proposal is remove force unwrapping(`!`) from function signatures, cause it have no sense, and that confuse new users.<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt;&gt;&gt; swift-evolution mailing list<br>
&gt;&gt;&gt;&gt;&gt; <a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
&gt;&gt;&gt;&gt;&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt;&gt; swift-evolution mailing list<br>
&gt;&gt;&gt;&gt; <a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
&gt;&gt;&gt;&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; swift-evolution mailing list<br>
&gt;&gt; <a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
&gt;&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
&gt;<br>
<br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">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>
</blockquote></div><div dir="ltr">-- <br></div><div data-smartmail="gmail_signature"><div dir="ltr">-Saagar Jha</div></div>