<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div>+1 for keeping failable initializers. Error handling should be reserved for errors and not be used for control flow or logic.</div><div><br></div><div>-Thorsten </div><div><br>Am 27.12.2015 um 18:11 schrieb Chris Lattner via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>>:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html charset=utf-8">On Dec 27, 2015, at 5:22 AM, Manfred Lau via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><div><blockquote type="cite" class="">I just found that the design of failable initializer is redundant in Swift 2. Because native error handling already has been introduced in Swift 2, and failable initializer indeed could be achieved by following codes:<br class=""></blockquote><br class=""></div><div>I’d be opposed to removing failable initializers. Failable inits introduce a symmetry into the language for initializers, which make them possible to do (almost) all of what you can do with a normal method. This capability is key for them to be able to replace “factory” static methods, which allows Swift to offer a consistent initialization pattern for clients of types.</div><div><br class=""></div><div>If we forced people to use error handling for anything that could return nil, then things like String to Int conversions would most likely not use initialization syntax.</div><div><br class=""></div><div>Besides that, over use of error handling waters it down and makes it less valuable in itself. For more information on this, please see the design discussion for error handling:</div><div class=""><a href="https://github.com/apple/swift/blob/master/docs/ErrorHandlingRationale.rst" class="">https://github.com/apple/swift/blob/master/docs/ErrorHandlingRationale.rst</a></div><div class=""><br class=""></div><div class="">-Chris</div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=1MXK54sosN3xru3iYcLt0oBZ2w20i49gyogXctgrspd5y7yS5NzzFvD4HEj3aTB4sYwv4Rfl2YuLeMdleOEgnUi8HYCKqIjMC1fwWOZ-2Fl1vgFYrVCzWK6L0bS0QtkQqEtkcjkaMaQgOHiJRM7GxnFaBBPcAmG7NVLq2QRRWeBMxU3z2MaGgu1iT6WEyzvII5de7DJCtc-2FILHqBdREXv3FaaTSzvVRWXSOrmQ2gqupgo-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;">
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></body></html>