{"id":29926,"date":"2020-08-27T15:55:01","date_gmt":"2020-08-27T19:55:01","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=29926"},"modified":"2020-08-31T16:09:13","modified_gmt":"2020-08-31T20:09:13","slug":"objective-rust","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2020\/08\/27\/objective-rust\/","title":{"rendered":"Objective-Rust"},"content":{"rendered":"<p><a href=\"https:\/\/belkadan.com\/blog\/2020\/08\/Objective-Rust\/\">Jordan Rose<\/a>:<\/p>\n<blockquote cite=\"https:\/\/belkadan.com\/blog\/2020\/08\/Objective-Rust\/\"><p>What I wanted was for Objective-C&rsquo;s messaging syntax, or something like it, to be valid anywhere in Rust code. It didn&rsquo;t have to be exactly Objective-C, but I quickly realized the <em>advantage<\/em> of Objective-C&rsquo;s syntax: it&rsquo;s delimited, i.e. it&rsquo;s a self-contained expression that can be dropped into something larger without changing how that larger thing parses. (That&rsquo;s probably why it&rsquo;s bracketed in C as well.)<\/p><p>[&#8230;]<\/p><p>If I were <em>just<\/em> matching that, I could use Rust&rsquo;s original <a href=\"https:\/\/doc.rust-lang.org\/book\/ch19-06-macros.html#declarative-macros-with-macro_rules-for-general-metaprogramming\">pattern-matching macros<\/a>. But to take a whole block of code, and replace everything that looks like a message lock <em>in<\/em> that block&#8230;well, it might be possible with pattern-matching and quite a bit of recursion, but it&rsquo;s going to be a lot easier to use <em><a href=\"https:\/\/blog.rust-lang.org\/2018\/12\/21\/Procedural-Macros-in-Rust-2018.html\">procedural macros<\/a>,<\/em> a Rust macro interface written in Rust and used as a compiler plugin. (Swift folks, basically what <a href=\"https:\/\/github.com\/apple\/swift-syntax\">SwiftSyntax<\/a> allows you to do, but invoked on-demand during compilation.)<\/p><\/blockquote>\n\n<p id=\"objective-rust-update-2020-08-31\">Update (2020-08-31): See also: <a href=\"https:\/\/news.ycombinator.com\/item?id=24309565\">Hacker News<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<p>Jordan Rose: What I wanted was for Objective-C&rsquo;s messaging syntax, or something like it, to be valid anywhere in Rust code. It didn&rsquo;t have to be exactly Objective-C, but I quickly realized the advantage of Objective-C&rsquo;s syntax: it&rsquo;s delimited, i.e. it&rsquo;s a self-contained expression that can be dropped into something larger without changing how that [&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":"2020-08-27T19:55:04Z","apple_news_api_id":"03fde7f2-c20d-425b-8f95-4817a52ec182","apple_news_api_modified_at":"2020-08-31T20:09:16Z","apple_news_api_revision":"AAAAAAAAAAAAAAAAAAAAAA==","apple_news_api_share_url":"https:\/\/apple.news\/AA_3n8sINQluPlUgXpS7Bgg","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":[69,46,1666,941,54,71,408],"class_list":["post-29926","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-cocoa","tag-languagedesign","tag-macos-10-15","tag-macros","tag-objective-c","tag-programming","tag-rust-lang"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/29926","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=29926"}],"version-history":[{"count":2,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/29926\/revisions"}],"predecessor-version":[{"id":29964,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/29926\/revisions\/29964"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=29926"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=29926"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=29926"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}