{"id":1168,"date":"2011-06-16T16:23:51","date_gmt":"2011-06-16T20:23:51","guid":{"rendered":"http:\/\/www.sporks.org\/blog\/?p=1168"},"modified":"2011-06-16T16:23:51","modified_gmt":"2011-06-16T20:23:51","slug":"introduction-to-pharen-a-lisp-to-php-compiler","status":"publish","type":"post","link":"https:\/\/www.sporks.org\/blog\/?p=1168","title":{"rendered":"Introduction to Pharen , A Lisp to PHP compiler"},"content":{"rendered":"<div class='posterous_autopost'>\n<div class=\"posterous_bookmarklet_entry\">\n<blockquote>\n<div>\n<h3>Introduction to Pharen<\/h3>\n<p>Pharen is a compiler that takes a <a href=\"http:\/\/en.wikipedia.org\/wiki\/Lisp_%28programming_language%29\">Lisp<\/a>-like language and turns it into <a href=\"http:\/\/php.net\/\">PHP<\/a> code. This combines Lisp\u00e2\u20ac\u2122s advantages of uniform syntax and homoiconicity (among others) and PHP\u00e2\u20ac\u2122s advantage of\u00e2\u20ac\u00a6being <em>everywhere<\/em>. Here\u00e2\u20ac\u2122s some sample Pharen and the equivalent PHP:<\/p>\n<div>\n<div>\n<div class=\"CodeRay\">\n<div class=\"code\">\n<div class=\"CodeRay\">\n<div class=\"code\">\n<pre>(fn greet-person (name) (. &quot;Hello &quot; name &quot;!&quot;))  (echo (greet-person &quot;visitor&quot;))<\/pre>\n<\/div><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div>\n<div>\n<div class=\"CodeRay\">\n<div class=\"code\">\n<div class=\"CodeRay\">\n<div class=\"code\">\n<pre>&lt;?php function greet_person($name){ return &quot;Hello &quot; . $name . &quot;!&quot;; }  echo greet_person(&quot;visitor&quot;); ?&gt;<\/pre>\n<\/div><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<p>This shows some of the differences between the two languages. Variables don\u00e2\u20ac\u2122t need the <code>$<\/code> prefix, hyphens in names for functions (and variables) are converted to underscores, everything, including string concatenation, looks like a function call, and most things are expressions. The last one means that a function will automatically return the last evaluated expression inside it. More will be explained in later sections.<\/p>\n<p>Some of the rationale behind Pharen:<\/p>\n<ol>\n<li>Abstract out problems and irregularities in PHP\u00e2\u20ac\u2122s own parser and the language itself.<\/li>\n<li>Compile more sophisticated features, such as closures and macros, to native PHP.<\/li>\n<li>Insanity.<\/li>\n<\/ol><\/div>\n<\/blockquote>\n<div class=\"posterous_quote_citation\">via <a href=\"http:\/\/scriptor.github.com\/pharen\/\">scriptor.github.com<\/a><\/div>\n<p>i can&#8217;t believe it. there is something like this. it is just too weird.. heck i might want to try this..<\/p>\n<\/div>\n<p style=\"font-size: 10px;\"> <a href=\"http:\/\/posterous.com\">Posted via email<\/a>  from <a href=\"http:\/\/shazbagl.com\/introduction-to-pharen-a-lisp-to-php-compiler\">alex chan&#8217;s posterous<\/a> <\/p>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Introduction to Pharen Pharen is a compiler that takes a Lisp-like language and turns it into PHP code. This combines Lisp\u00e2\u20ac\u2122s advantages of uniform syntax and homoiconicity (among others) and PHP\u00e2\u20ac\u2122s advantage of\u00e2\u20ac\u00a6being everywhere. Here\u00e2\u20ac\u2122s some sample Pharen and the equivalent PHP: (fn greet-person (name) (. &quot;Hello &quot; name &quot;!&quot;)) (echo (greet-person &quot;visitor&quot;)) &lt;?php function [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1168","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.sporks.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1168","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sporks.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sporks.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sporks.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sporks.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1168"}],"version-history":[{"count":0,"href":"https:\/\/www.sporks.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1168\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sporks.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1168"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sporks.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1168"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sporks.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1168"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}