Re: FWD:Re: refactoring
Joel de Guzman <[email protected]>
| Newsgroups | gmane.comp.documentation.synopsis |
|---|---|
| Message-ID | <[email protected]> |
David Abrahams wrote: > Joel de Guzman <[email protected]> writes: > > >>>>We can provide optimized >>>>intrinsics specific to, say, MPL and type_traits, that would >>>>be "compiled" instead of "interpreted" in the POV of the meta >>>>domain. >>> >>>Okay, that we could do, if there was a way to give the compiler >>>special knowledge of particular metafunctions. So you're thinking of >>>something like: >>> #ifndef BOOST_META_COMPILER_EXTENSION >>> // normal mpl::if_ implementation here >>> #else >>> template <class C, class T, class F> >>> struct if_ : (cond C T F) // Code for your interpreter. >>> {}; >>> #endif > > > Is that what you meant? Yes. Something like it. To be honest, the basic ideas are still forming and I have not reached that point yet. What you have above looks good. >>>>Such would give dramatic improvements in parse/compile >>>>time. >>> >>>Yes, it might! It seems to me that you could bypass many of the >>>usual >>>costs of template instantiation. >>>I think this is a really interesting alternative to David >>>Vandevoorde's metacode approach. One of my big concerns about >>>metacode is that it has not yet been shown to offer improved solutions >>>in the area of some of the major applications of TMP. For example, >>>David and I looked at how to implement lambda in metacode, and didn't >>>get far. > > > Just to elaborate: if I understood your idea right, this one has a > clear mapping onto the constructs we already use for metaprogramming; > it simply builds the bodies of instantiated classes imperatively. It Yes. It bypasses the "interpretation" of the template, when instantiated. Quite similar to a python script implemented in raw C++ to give the performance boost that it needs. > seems much more obvious that this can be useful for the things we're > already trying to do. I think so, yes. >>Yes. If the formalized compile time interpreter is simple enough >>like the language Scheme, we can easily have a compile time >>meta-compiler-compiler that compiles directly to compiler object >>code. > > > That too. > > >>Then, TMP infrastructure libraries such as MPL can start doing >>meta-meta-programming :-) > > > Even I am not ready for that idea ;-) Too ambitious perhaps. A reasonably modest goal is (after formalizing the compiler language), to create a mechanism that allows various time critical functions to be exposed to the underlying host compiler (in much the same way that Boost Python is doing for Python), so it can be implemented in fast native code (imperative c++, of course). Consequently, the underlying host compiler should also allow third parties to hook into the "wrapping mechanism" through a well defined API. Regards, -- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net