<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="">Hi Fernando,&nbsp;<div class=""><br class=""></div><div class="">Some projects use a result type to unify the error handling.&nbsp;<a href="https://github.com/antitypical/Result" class="">https://github.com/antitypical/Result</a></div><div class=""><br class=""></div><div class="">There has been discussions about this and Chris L thinks that we may get a native (constrained) result type at some point.&nbsp;</div><div class=""><br class=""></div><div class=""><div class=""><a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160125/007858.html" class="">https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160125/007858.html</a></div><div class=""><a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160125/008057.html" class="">https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160125/008057.html</a></div></div><div class=""><br class=""></div><div class="">I can see a future where these get unified but the main issue imo is cocoa compatibility.&nbsp;</div><div class=""><br class=""></div><div class="">Probably swift 5+</div><div class=""><br class=""></div><div class="">Cheers!,</div><div class="">J. Cheyo</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Aug 5, 2016, at 4:50 PM, Fernando Rodríguez via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi,<div class=""><br class=""></div><div class="">I do a lot of training and one of the features of Swift that seems more confusing to students (and myself) is error handling. There are too many ways of doing it, and none seems satisfactory.</div><div class=""><br class=""></div><div class="">Let's take for example an initializer. There are 2 different ways of handling errors within an init:</div><div class=""><br class=""></div><div class="">a) Old School: return nil. This was very simple in Objective C, because the uncommon case of an error could be easily ignored...until everything crashed.</div><div class=""><br class=""></div><div class="">In Swift it's not easy (nor advisable IMHO) to completely ignore the possibility of an error. Besides, it has 2 complications.</div><div class=""><br class=""></div><div class="">First of all, you return an Optional, and Optionals have a tendency to go viral. Suddenly, all your code has to deal with optionals.</div><div class=""><br class=""></div><div class="">Secondly, you have no information about the error itself.</div><div class=""><br class=""></div><div class="">b) do/try/catch</div><div class=""><br class=""></div><div class="">This allows you to have information about the error, but also causes the newly created object to be "trapped" inside a do block.</div><div class=""><br class=""></div><div class="">Are there any plans to address this situation? I believe there should be a single, obvious and convenient way of handling errors in the language.</div><div class=""><br class=""></div><div class="">What do you guys think?</div><div class=""><br class=""></div><div class=""><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr" class=""><div class=""><br class=""></div><div class=""><div dir="ltr" style="font-family:arial;font-size:small;line-height:normal" class=""><table width="400" border="0" cellspacing="0" cellpadding="0" style="font-family: Times;" class=""><tbody class=""><tr class=""><td width="150" rowspan="3" align="center" valign="top" class=""><br class=""><table border="0" cellspacing="0" cellpadding="0" style="font-family:Times;border-collapse:collapse;border:none" class=""><tbody class=""><tr class=""><td width="112" valign="top" style="width:111.75pt;padding:0cm 5.4pt" class=""><div class=""><br class="webkit-block-placeholder"></div><p class=""><b class=""><span lang="ES" style="font-family:Helvetica;color:rgb(213,117,7)" class=""><a href="http://keepcoding.io/es/" style="color:rgb(17,85,204)" target="_blank" class=""><img src="https://docs.google.com/uc?export=download&amp;id=0Bzx0v_J9FCNPNllTZ19uM1hxbXc&amp;revid=0Bzx0v_J9FCNPb2trZU1BWXFabFdkUngvd0Nmd2Q4ZTdWaHNNPQ" width="200" height="138" class=""></a></span></b></p></td></tr></tbody></table><br class=""><br class=""></td><td style="font-family:Helvetica,Arial,sans-serif;font-size:12px;color:rgb(100,100,100)" class=""><div style="margin: 0px; font-size: 14px; font-family: Helvetica; color: rgb(64, 64, 64);" class=""><b class="">Fernando Rodríguez</b></div><div style="margin: 0px; font-family: Helvetica;" class="">m. +34 610 965 332</div><div style="margin: 0px; font-family: Helvetica;" class="">t. +34 91 629 57 61</div><div style="margin: 0px; font-family: Helvetica;" class=""><a href="mailto:fernando@agbo.biz" target="_blank" class="">fernando@k</a><a href="http://eepcoding.io/" target="_blank" class="">eepcoding.io</a></div><div style="margin: 0px; font-family: Helvetica;" class=""><span class=""><img alt="pastedGraphic.png" class=""></span><span style="font-size:16px;font-family:Arial;color:rgb(35,35,35)" class="">&nbsp;</span><img alt="pastedGraphic_1.png" class=""><span style="font-size:16px;font-family:Arial;color:rgb(35,35,35)" class="">&nbsp;</span><img alt="pastedGraphic_2.png" class=""></div><div style="margin: 0px; font-size: 10px; font-family: Helvetica; color: rgb(64, 64, 64);" class=""><b class=""><a href="http://keepcoding.io" class="">KeepCoding.io</a></b></div><div style="margin: 0px; font-size: 10px; font-family: Helvetica; color: rgb(64, 64, 64);" class="">2120 University Avenue, Berkeley, CA</div><div style="margin: 0px; font-size: 10px; font-family: Helvetica; min-height: 12px;" class=""><br class=""></div><div style="margin: 0px; font-size: 10px; font-family: Helvetica;" class="">Avda. Fuencarral, 44, Ed. 8, Loft 30</div><div style="margin: 0px; font-size: 10px; font-family: Helvetica;" class="">28108 Alcobendas (Madrid) Spain</div><div class=""><br class=""></div></td></tr></tbody></table></div><div style="font-family: Helvetica;" class=""><div dir="ltr" style="color:rgb(34,34,34);font-family:arial;font-size:small;line-height:normal" class=""><table width="75%" border="0" cellspacing="0" cellpadding="0" style="font-family: Times;" class=""><tbody class=""><tr class=""><td style="font-family:Verdana;font-size:7px;color:rgb(153,153,153);padding-top:10px;text-align:justify" class=""><br class=""></td></tr></tbody></table></div></div></div></div></div>
</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=""></div></body></html>