I have come across a different method for embedding a DSL in C++, namely the one used by Rapidmind (previously libsh http://libsh.org). I believe Intel's Ct and Google's Peakstream also use a method similar to Rapidmind. A DSL program in this style would look as follows :
Program p; p = BEGIN { In<Value3d> a, b; Out<Value3d> c; Value3d d = sin(a, b); IF(all(d > 0.0)) { c = d + a*2.0; } ELSE { c = d - a*2.0; } ENDIF; } END; I don't claim to know all the details, but from the looks of it, this method seems distinctly different than Proto's. In the above method, the AST for the code fragment gets built at runtime. There is still some operator overloading going on, but the semantic actions are all fixed. In this case, the operator overload for, say +, directly builds the AST fragment for plus. IF and ELSE macros probably begin new scopes in the AST, and ENDIF ends the scope. BEGIN macro sets up a current context for the AST builder and the following code (until END) all get added to that scope. Now, Proto is a much more general framework, but if I were to just embed a C like language inside C++, I would say this method is pretty good. And judging by its acceptance in the industry, I would say it's quite practical. So what do you guys think of this? Manjunath P.S : Someone more familiar with Rapidmind or other variants, can you please explain how they do it in more detail? _______________________________________________ proto mailing list proto@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/proto