{"id":21339,"date":"2018-04-23T14:22:41","date_gmt":"2018-04-23T18:22:41","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=21339"},"modified":"2018-04-23T14:22:41","modified_gmt":"2018-04-23T18:22:41","slug":"forcing-compiler-errors-in-swift","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2018\/04\/23\/forcing-compiler-errors-in-swift\/","title":{"rendered":"Forcing Compiler Errors in Swift"},"content":{"rendered":"<p><a href=\"https:\/\/ericasadun.com\/2018\/04\/18\/forcing-compiler-errors-in-swift\/\">Erica Sadun<\/a>:<\/p>\n<blockquote cite=\"https:\/\/ericasadun.com\/2018\/04\/18\/forcing-compiler-errors-in-swift\/\">\n<p>Swift&rsquo;s newly adopted <code>#error<\/code>&nbsp;and <code>#warning<\/code>&nbsp;directives represents a big step up from current practices, which often rely on run-time rather than compile-time feedback.<\/p>\n<p>[&#8230;]<\/p>\n<p>Here&rsquo;s an example I discovered from John Estropia. (He, in turn, cribbed it from one of &nbsp;his co-workers.) He uses conditional compilation to set a <code>TODO<\/code>&nbsp;or <code>FIXME<\/code>&nbsp;(or whatever) typealias then uses it in-line at points where a debug build should compile and release builds should error:<\/p>\n<pre>#if DEBUG \ninternal typealias TODO&lt;T&gt; = T\n#endif\n\nprint(\"Remove this later\") as TODO<\/pre>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Erica Sadun: Swift&rsquo;s newly adopted #error&nbsp;and #warning&nbsp;directives represents a big step up from current practices, which often rely on run-time rather than compile-time feedback. [&#8230;] Here&rsquo;s an example I discovered from John Estropia. (He, in turn, cribbed it from one of &nbsp;his co-workers.) He uses conditional compilation to set a TODO&nbsp;or FIXME&nbsp;(or whatever) typealias then [&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":"2018-04-23T18:22:43Z","apple_news_api_id":"7379ac7f-27e0-4465-8e87-77082c451d4d","apple_news_api_modified_at":"2018-04-23T18:22:43Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/Ac3msfyfgRGWOh3cILEUdTQ","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-21339","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\/21339","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=21339"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/21339\/revisions"}],"predecessor-version":[{"id":21340,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/21339\/revisions\/21340"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=21339"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=21339"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=21339"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}