From: Brian Adkins Date: 2009-02-26T02:44:17+09:00 Subject: Re: Nexus Programming Language 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/