<div dir="ltr">+1 I agree. Unwrapping in the functional signature is confusing for the user; many don’t realize that it puts the burden of checking on them. Non-optional function parameters make this explicit by preventing passing in Optional types, forcing the user to check, which they should be doing anyway.<br></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Jun 8, 2016 at 12:22 PM J. Charles M. N. via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
This confused me at the beginning.<br>
<br>
But doesn't Int! In parameter type means the function is awaiting an unwrapped value so the user should ensure that it data parameter is available, valid, and unwrapped?<br>
<br>
--<br>
J. Charles<br>
<br>
> Le 8 juin 2016 à 13:30, Spromicky via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> a écrit :<br>
><br>
> Hello, everyone!<br>
><br>
> 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>
> People who new in swift look at how they old Obj-C code (without nullability modifiers) translate in to swift:<br>
><br>
> Obj-C:<br>
> - (void)foo:(NSInteger)bar {<br>
> //...<br>
> }<br>
><br>
> Swift transaliton:<br>
> func foo(bar: Int!) {<br>
> //...<br>
> }<br>
><br>
> And think that force unwrapping in signature is good practice. And start write functions in clear swift code like this:<br>
><br>
> func newFoo(bar: Int!) {<br>
> //...<br>
> }<br>
><br>
> and use it like this:<br>
><br>
> let bar: Int? = 1<br>
> newFoo(bar)<br>
><br>
> And it really work, and they does not think that this can crash in case if `bar` will be `nil`.<br>
> But in clear swift we wanna work with parametrs in function that clearly or optional, or not.<br>
><br>
> func newFoo(bar: Int) {<br>
> //...<br>
> }<br>
><br>
> or<br>
><br>
> func newFoo(bar: Int?) {<br>
> //...<br>
> }<br>
><br>
> When we write a new function we know what we need in this case and use optional params or not.<br>
><br>
> So my proposal is remove force unwrapping(`!`) from function signatures, cause it have no sense, and that confuse new users.<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>
_______________________________________________<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>