{"id":9180,"date":"2014-07-19T20:11:32","date_gmt":"2014-07-20T00:11:32","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=9180"},"modified":"2015-02-11T09:32:57","modified_gmt":"2015-02-11T14:32:57","slug":"building-assert-in-swift","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2014\/07\/19\/building-assert-in-swift\/","title":{"rendered":"Building assert() in Swift"},"content":{"rendered":"<p><a href=\"https:\/\/developer.apple.com\/swift\/blog\/?id=4\">Apple<\/a>:<\/p>\r\n<blockquote cite=\"https:\/\/developer.apple.com\/swift\/blog\/?id=4\"><p>When designing Swift we made a key decision to do away with the C preprocessor, eliminating bugs and making code much easier to understand. This is a big win for developers, but it also means Swift needs to implement some old features in new ways.  Most of these features are obvious (importing modules, conditional compilation), but perhaps the most interesting one is how Swift supports macros like <code>assert()<\/code>.<\/p>\r\n<\/blockquote>\r\n<p><code>@auto_closure<\/code> is great, but I still <a href=\"http:\/\/mjtsai.com\/blog\/2014\/07\/13\/swift-and-cocoa-error-handling\/\">wish for<\/a> the power of actual macros.<\/p>\r\n<p>Update (2015-02-11): <a href=\"https:\/\/developer.apple.com\/swift\/blog\/?id=15\">Part 2<\/a> introduces <code>__FILE__<\/code> and <code>__LINE__<\/code>. Swift does not have a way of capturing the expression as a string, among other <a href=\"http:\/\/mjtsai.com\/blog\/2015\/01\/30\/swift-no-macros-no-compromises\/\">limitations<\/a> from not having macros.<\/p>","protected":false},"excerpt":{"rendered":"<p>Apple: When designing Swift we made a key decision to do away with the C preprocessor, eliminating bugs and making code much easier to understand. This is a big win for developers, but it also means Swift needs to implement some old features in new ways. Most of these features are obvious (importing modules, conditional [&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,941,71,901],"class_list":["post-9180","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-languagedesign","tag-macros","tag-programming","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/9180","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=9180"}],"version-history":[{"count":2,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/9180\/revisions"}],"predecessor-version":[{"id":10738,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/9180\/revisions\/10738"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=9180"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=9180"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=9180"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}