<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jun 29, 2017, at 12:23 PM, Djura Retired Hunter via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div><div class=""><div class=""><blockquote type="cite" class=""><div class="">Il giorno 29 giu 2017, alle ore 19:05, Erica Sadun via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> ha scritto:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jun 29, 2017, at 9:13 AM, Dave DeLong <<a href="mailto:delong@apple.com" class="">delong@apple.com</a>> wrote:</div><div class=""><div style="font-family: Palatino-Roman; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Palatino-Roman; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">My usage of “!!” generally falls in to two big buckets:</div><div style="font-family: Palatino-Roman; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div></div></blockquote><br class=""></div><div class="">I've incorporated all the feedback to date and updated the gist:</div><div class=""><br class=""></div><div class=""><a href="https://gist.github.com/erica/423e4b1c63b95c4c90338cdff4939a9b" class="">https://gist.github.com/erica/423e4b1c63b95c4c90338cdff4939a9b</a></div><div class=""><br class=""></div><div class="">-- E</div></div></div></blockquote></div><br class=""></div><div class="">In my opinion the phrase "An often-touted misconception ... a serious failure." taken from Ben Cohen's comment should not be included in the proposal because, other than being a personal opinion, it's a extremely generic statement that doesn't suggest at all "when" force unwrap is good and it's not useful as a guideline for people that read this things to learn something. Saying things like "this is kind of ok but too much of it is wrong" is not useful.</div><div class=""><br class=""></div><div class=""><div class=""><blockquote type="cite" class=""><div class=""><div class="">// in a custom view controller subclass that only accepts children of a certain kind:</div><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(186, 45, 162);">let</span><span class=""> existing = childViewControllers </span><span class="" style="color: rgb(186, 45, 162);">as</span><span class="">? </span><span class="" style="color: rgb(112, 61, 170);">Array</span><span class=""><</span><span class="" style="color: rgb(112, 61, 170);">TableRowViewController</span><span class="">> !! </span>"TableViewController must only have TableRowViewControllers as children"</div></div><div class=""><br class=""></div></div></blockquote></div><br class=""><div class="">In my opinion this example shows very well how you can always switch the need to force unwrap with a more specific contract for a class, or in other words, with a more specific type. Instead of referring to childViewControllers, you could simply have an array of objects of the specific type that mediates the addition and reference to the underlying "childViewControllers" storage. It uses the type system to enforce correctness.</div></div></div></div></blockquote><div><br class=""></div><div>This is getting off on a tangent, but the interface I wrote for my TableViewController does that.</div><div><br class=""></div><div><i class="">However</i></div><div><i class=""><br class=""></i></div><div>Since it is a subclass of NS/UIViewController, the `childViewControllers` property is public and directly mutable by anyone. Thus, the assertion that the class is not being misused.</div><div><br class=""></div><div>Dave</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">Now, I'm NOT saying that force unwrapping is always bad, but adding examples like these to a official proposal could make people think that force unwrapping is a perfectly fine thing to do for production code instead of designing types for safety, and safety enforced with a strong type system IS a cornerstone of Swift, like it or not, as reported on <a href="http://swift.org/about:" class="">swift.org/about:</a> "The most obvious way to write code should also behave in a safe manner. Undefined behavior is the enemy of safety, and developer mistakes should be caught before software is in production. Opting for safety sometimes means Swift will feel strict, but we believe that clarity saves time in the long run.".</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Elviro</div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>