Re: [proto] Recursive functions in a mini language

2010-08-06 Thread Manjunath Kudlur
 Careful here. You want BOOST_PROTO_AUTO, or else put these things in a
 domain defined such that intermediate expressions are not held by
 reference. Or else, make declare_module an instance of a type with an
 overloaded operator[] that deep-copies it's rhs to avoid all lifetime
 issues. Proto expression templates are make entirely of temporary
 object. Here be dragons.

I didn't think about lifetime issues yet, though I meant to use
BOOST_PROTO_AUTO.

 Let me understand. Your goal is to have something like spirit subrules,
 except the subrules are like ordinary functions, and the functions
 should be invokable by name, is that right? Spirit subrules are neat and
 tidy and efficient because they are hidden away inside a grammar. But
 that's not your case. Hence the need for the module and the operator-*.
 Did I get that right?


Yes. I know with Spirit subrules, one only exposes the top level rule
and the auxiliary rules are hidden inside the grammar. Here, my goal
is to provide the user with a mechanism to define a set of mutually
recursive functions, and he should be able to call any of the
functions. He has to do module-*func(...) and cannot do just
func(...) because the definitions of functions are contained in the
module.

Manjunath

 Eric Niebler
 BoostPro Computing
 http://www.boostpro.com
 ___
 proto mailing list
 proto@lists.boost.org
 http://lists.boost.org/mailman/listinfo.cgi/proto

___
proto mailing list
proto@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/proto


Re: [proto] Other methods for embedding DSL in C++

2010-07-26 Thread Manjunath Kudlur
 I confess I'm having a hard time seeing how the code posted in
 Manjunath's original email could result in something that can be
 introspected at runtime. Does it generate byte code? A runtime
 polymorphic AST? And the JIT ... does it actually generate machine code
 that then gets executed?

At the end of the END block, you would have an AST. Yes, there will be
a JIT and an associated run time to compile this and run on different
platforms.

 P.S : Someone more familiar with Rapidmind or other variants, can you
 please explain how they do it in more detail?

 Rapidmind is one huge vaporware. Nobody ever saw it running ...

 Manjunath asked about why this technique is popular in industry. I don't
 know; I've never heard about it before. Is it because it's easier then
 programming with expression templates? Maybe had proto been available

You wouldn't believe how many of my otherwise expert C++ programmer
friends get a disgusted look on their face when they see templates. I
couldn't figure out why :(
That being said, I see one obvious advantage with proto. With proto,
when you write an expression like
if_(a  b) [c = d + 2.0*a].else_[c = d-2.0*a]
you can just natively execute it. But with RT-DSLs, you have to
generate an AST by running the code, then JIT and only then you can
execute it. If you wanted a system where you can just natively
interpret you program, or generate code for different platforms,
then proto makes the interpreter very fast. Whereas with RT-DSLs, even
interpreting has to be differed to run time.

Manjunath
___
proto mailing list
proto@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/proto