{"id":263,"date":"2014-06-13T06:30:49","date_gmt":"2014-06-13T14:30:49","guid":{"rendered":"http:\/\/blog.danielparnell.com\/?p=263"},"modified":"2014-06-21T15:12:20","modified_gmt":"2014-06-21T23:12:20","slug":"the-first-stage-of-my-port-of-pegged-to-swift-is-successful","status":"publish","type":"post","link":"https:\/\/blog.danielparnell.com\/?p=263","title":{"rendered":"The first stage of my port of pegged to Swift is successful :)"},"content":{"rendered":"<p>I have managed to get the Objective-C version of <a href=\"https:\/\/github.com\/dparnell\/pegged\">pegged<\/a> to spit out a parser using Swift rather than Objective-C \ud83d\ude42<\/p>\n<p>It&#8217;s getting late, so I really should get some sleep.<\/p>\n<p>I finally figured out what was causing the compiler to crash. \u00c2\u00a0The following code will crash the Swift compiler unless the inout parameter to the block type is removed.<\/p>\n<div style=\"background-color: #333; font-family: Lucida Console, Monaco, monospace;\">\n<div class=\"p1\" style=\"color: #ffffff;\"><span class=\"s1\" style=\"color: #c2349b;\">typealias<\/span>\u00c2\u00a0MathFunction = (a:\u00c2\u00a0<span class=\"s2\" style=\"color: #00afca;\">Double<\/span>, b:<span class=\"s2\" style=\"color: #00afca;\">Double<\/span>, inout x:<span class=\"s2\" style=\"color: #00afca;\">Int<\/span>) -&gt;\u00c2\u00a0<span class=\"s2\" style=\"color: #00afca;\">Double<\/span><\/div>\n<div class=\"p1\" style=\"color: #ffffff;\"><span class=\"s1\" style=\"color: #c2349b;\">var<\/span>\u00c2\u00a0counter =\u00c2\u00a0<span class=\"s3\" style=\"color: #8b84cf;\">0<\/span><\/div>\n<div class=\"p1\" style=\"color: #ffffff;\"><span class=\"s1\" style=\"color: #c2349b;\">class<\/span>\u00c2\u00a0Executor {<\/div>\n<div class=\"p3\" style=\"color: #93c86a;\"><span class=\"s4\" style=\"color: #ffffff;\">\u00c2\u00a0 \u00c2\u00a0<span class=\"Apple-converted-space\">\u00c2\u00a0<\/span><\/span><span class=\"s1\" style=\"color: #c2349b;\">var<\/span><span class=\"s4\" style=\"color: #ffffff;\">\u00c2\u00a0fn:\u00c2\u00a0<\/span>MathFunction<\/div>\n<div class=\"p1\" style=\"color: #ffffff;\">\u00c2\u00a0 \u00c2\u00a0<span class=\"Apple-converted-space\">\u00c2\u00a0<\/span><span class=\"s1\" style=\"color: #c2349b;\">init<\/span>(fn:\u00c2\u00a0<span class=\"s5\" style=\"color: #93c86a;\">MathFunction<\/span>) {<\/div>\n<div class=\"p1\" style=\"color: #ffffff;\">\u00c2\u00a0 \u00c2\u00a0 \u00c2\u00a0 \u00c2\u00a0<span class=\"Apple-converted-space\">\u00c2\u00a0<\/span><span class=\"s1\" style=\"color: #c2349b;\">self<\/span>.<span class=\"s5\" style=\"color: #93c86a;\">fn<\/span>\u00c2\u00a0= fn<\/div>\n<div class=\"p1\" style=\"color: #ffffff;\">\u00c2\u00a0 \u00c2\u00a0<span class=\"Apple-converted-space\">\u00c2\u00a0<\/span>}<\/div>\n<div class=\"p1\" style=\"color: #ffffff;\">\u00c2\u00a0 \u00c2\u00a0<span class=\"Apple-converted-space\">\u00c2\u00a0<\/span><span class=\"s1\" style=\"color: #c2349b;\">func<\/span>\u00c2\u00a0execute(a:\u00c2\u00a0<span class=\"s2\" style=\"color: #00afca;\">Double<\/span>, b:\u00c2\u00a0<span class=\"s2\" style=\"color: #00afca;\">Double<\/span>) -&gt;\u00c2\u00a0<span class=\"s2\" style=\"color: #00afca;\">Double<\/span>\u00c2\u00a0{<\/div>\n<div class=\"p1\" style=\"color: #ffffff;\">\u00c2\u00a0 \u00c2\u00a0 \u00c2\u00a0 \u00c2\u00a0<span class=\"Apple-converted-space\">\u00c2\u00a0<\/span><span class=\"s1\" style=\"color: #c2349b;\">return<\/span>\u00c2\u00a0<span class=\"s5\" style=\"color: #93c86a;\">fn<\/span>(a: a, b: b, x: &amp;<span class=\"s5\" style=\"color: #93c86a;\">counter<\/span>)<\/div>\n<div class=\"p1\" style=\"color: #ffffff;\">\u00c2\u00a0 \u00c2\u00a0<span class=\"Apple-converted-space\">\u00c2\u00a0<\/span>}<\/div>\n<div class=\"p1\" style=\"color: #ffffff;\">}<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>I have managed to get the Objective-C version of pegged to spit out a parser using Swift rather than Objective-C \ud83d\ude42 It&#8217;s getting late, so I really should get some sleep. I finally figured out what was causing the compiler to crash. \u00c2\u00a0The following code will crash the Swift compiler unless the inout parameter to &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.danielparnell.com\/?p=263\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;The first stage of my port of pegged to Swift is successful :)&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4,3,2,47],"tags":[49,66],"class_list":["post-263","post","type-post","status-publish","format-standard","hentry","category-cocoa","category-mac-os-x","category-programming","category-swift","tag-parser","tag-swift","entry"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p561S3-4f","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/blog.danielparnell.com\/index.php?rest_route=\/wp\/v2\/posts\/263","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.danielparnell.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.danielparnell.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.danielparnell.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.danielparnell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=263"}],"version-history":[{"count":1,"href":"https:\/\/blog.danielparnell.com\/index.php?rest_route=\/wp\/v2\/posts\/263\/revisions"}],"predecessor-version":[{"id":264,"href":"https:\/\/blog.danielparnell.com\/index.php?rest_route=\/wp\/v2\/posts\/263\/revisions\/264"}],"wp:attachment":[{"href":"https:\/\/blog.danielparnell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=263"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.danielparnell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=263"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.danielparnell.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=263"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}