From: pjb@... (Pascal J. Bourguignon) Date: 2009-02-26T06:24:22+09:00 Subject: Re: Nexus Programming Language Brian Adkins writes: > 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, Yes, definitely. I use emacs with paredit-mode. > or to compare > more directly with the Lisp example I elided, Not specifically, but it's a nice side effect. > or simply to try and > make your Ruby code look as much like Lisp as posisble, or ... ? Yes, definitely. It makes me feel if not at home, at least, at a strange aunt's, vs. in a totally strange home in a totally strange land. -- __Pascal Bourguignon__