On May 23, 2006, at 10:24 PM, Douglas Livingstone wrote: > 2006/5/24, Logan Capaldo <logancapaldo / gmail.com>: >> >> How about we rewrite the ruby runtime as a combination of macros and >> functions in Lisp, use ParseTree to get the S-Exp representation of a >> ruby program and then feed that into our Lisp compiler? Instant >> speedy ruby! ;) >> > > With an install of ParseTree: > > $ cat example.rb > #!/usr/local/bin/ruby > def sum(a, b) > return a+b > end > > a = 3 > b = 4 > c = pythag(a, b) > puts c > > $ cat lispify.rb > #!/usr/local/bin/ruby > > def lispify(code) > code.gsub!(/[:,]/, '') > code.gsub!(/\[/, '(') > code.gsub!(/\]/, ')') > end > > code = $stdin.read > > puts lispify(code) > > $ cat example.rb | parse_tree_show -f | ./lispify.rb > ((defn > sum > (scope > (block > (args a b) > (return (call (lvar a) + (array (lvar b))))))) > (lasgn a (lit 3)) > (lasgn b (lit 4)) > (lasgn c (fcall pythag (array (lvar a) (lvar b)))) > (fcall puts (array (lvar c)))) > > So, it looks like Lisp to me! Now, some macros? > > Douglas > What scares (excites?) me is that this looks almost close enough to work already.