{"id":15725,"date":"2016-09-06T21:02:07","date_gmt":"2016-09-07T01:02:07","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=15725"},"modified":"2016-09-06T21:02:07","modified_gmt":"2016-09-07T01:02:07","slug":"swift-3s-never","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2016\/09\/06\/swift-3s-never\/","title":{"rendered":"Swift 3&rsquo;s &ldquo;Never&rdquo;"},"content":{"rendered":"<p><a href=\"http:\/\/ericasadun.com\/2016\/09\/06\/its-now-or-never\/\">Erica Sadun<\/a>:<\/p>\n<blockquote cite=\"http:\/\/ericasadun.com\/2016\/09\/06\/its-now-or-never\/\"><p><a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0102-noreturn-bottom-type.md\">SE-0102<\/a> removes the rarely-used <code>@noreturn<\/code> function type and replaced it with a dead-end return type[&#8230;]<\/p><p>[&#8230;]<\/p><p><code>Never<\/code> allows a function or method to <code>throw<\/code>: e.g.<code> () throws -&gt; Never<\/code>. Throwing allows a secondary path for error remediation, even in functions that were not expected to return.<\/p><p>As a first class type, <code>Never<\/code> works with generics in a  way that the <code>@noreturn<\/code> attribute could not.<\/p><\/blockquote>\n\n<p><a href=\"http:\/\/ericasadun.com\/2016\/09\/06\/dear-erica-how-do-you-create-never-callbacks\/\">Erica Sadun<\/a>:<\/p>\n<blockquote cite=\"http:\/\/ericasadun.com\/2016\/09\/06\/dear-erica-how-do-you-create-never-callbacks\/\"><p>Guard conditions require you to exit scope. <code>Never<\/code> mean you cannot  <code>return<\/code> from your function. So, instead, add a simple <code>do<\/code>-scope layer[&#8230;]<\/p><\/blockquote>\n<p>Fortunately, I don&rsquo;t think this sort of contortion is commonly needed.<\/p>","protected":false},"excerpt":{"rendered":"<p>Erica Sadun: SE-0102 removes the rarely-used @noreturn function type and replaced it with a dead-end return type[&#8230;][&#8230;]Never allows a function or method to throw: e.g. () throws -&gt; Never. Throwing allows a secondary path for error remediation, even in functions that were not expected to return.As a first class type, Never works with generics in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[46,71,901],"class_list":["post-15725","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-languagedesign","tag-programming","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/15725","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=15725"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/15725\/revisions"}],"predecessor-version":[{"id":15726,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/15725\/revisions\/15726"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=15725"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=15725"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=15725"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}