From: Jason Roelofs Date: 2009-02-26T03:06:48+09:00 Subject: Re: Nexus Programming Language On Wed, Feb 25, 2009 at 12:44 PM, Brian Adkins wrote: > pjb@informatimago.com (Pascal J. Bourguignon) writes: > >> ... >> Here is for example how I generate C++ code from Ruby: >> >>       (class MapType >>          (def makeToStringExpression(fieldAccess , mandatory , inVector = false , encoding = nil) >>             (if mandatory >>                (e = fieldAccess) >>                (ib = [["." , e , :begin]]) >>                (ie = [["." , e , :end]]) >>              else >>                (e = [[ "." , fieldAccess , :getValuePtr]]) >>                (ib = [["->" , e , :begin]]) >>                (ie = [["->" , e , :end]]) >>              end) >>             (k = (@keyType     . makeToStringExpression(["->" , :i , :first]  , true , encoding))) >>             (v = (@elementType . makeToStringExpression(["->" , :i , :second] , true , encoding))) >>             (s = [:block , >>                   [:inline , "typedef " + (self . cxxPath) + " map_type;"] , >>                   (Cxx::Variable . new(:i , (Cxx::Type . new((self . cxxPath)+"::"+"const_iterator")) , ib)) , >>                   (Cxx::Variable . new(:e , (Cxx::Type . new((self . cxxPath)+"::"+"const_iterator")) , ie)) , >>                   [ "<<" , :s , " (map"] , >>                     [:for , [ nil , ["!=" , :i , :e],["post++",:i]] , >>                       [:block , ["<<", :s , " ("] , k , ["<<", :s , " . "] , v , ["<<", :s , ")"]]] , >>                    [ "<<" , :s , ")"]]) >>           end) >>        end) > > Pascal, I'm curious about your use of parentheses above. Do you use > them because it makes some things easier in your editor, or to compare > more directly with the Lisp example I elided, or simply to try and > make your Ruby code look as much like Lisp as posisble, or ... ? > > -- > Brian Adkins > http://lojic.com/ > > I think he was making a point to compare Ruby code with LISP code and showing how similar it is at the core. At least, that's what I saw. Jason