From: Giles Bowkett Date: 2006-05-26T02:04:57+09:00 Subject: Re: Zed and Luis drop the bomb on Ruby's poor performance I don't have ParseTree installed on my (dooky) work machine, I think I'll try this at home tho. But I have a question, apologies if it's obvious -- is that a superficial result or a meaningful result? It looks as if the magic missing link here is ParseTree. Can you just drop that output into a Lisp interpreter, badda bing badda boom? On 5/23/06, Logan Capaldo wrote: > > On May 23, 2006, at 10:24 PM, Douglas Livingstone wrote: > > > 2006/5/24, Logan Capaldo : > >> > >> 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. > > > > -- Giles Bowkett http://www.gilesgoatboy.org