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: > > >>WRT templates and the C++ type system, my current thinking is that >>I need an embedded runtime interpreter specifically geared to >>handling the C++ meta template language. It would be a minimalist >>FP language similar to scheme/lisp. > > > Sorry, I can't picture where you'd need this, or what you'd use it > for. More detail, please? Hmmm... Ok, I'll give it a shot: The C++ meta template language is a complete FP language that is executed (interpreted) at compile time one way or another. The advent of modern c++ and especially template meta programming makes me think that an adhoc solution to "interpreting" this language is no longer adequate. IMO, an elegant way to address this is to actually formalize the compile time interpreter. A template class can be modeled like a function with multiple arguments (template parameters) and multiple returns (typedefs). Types are values in the POV of the compile time interpreter. The notion of a "metafunction" will be just an ordinary function in the viewpoint of the compile time interpreter. Partial/full specializations will be cased and pattern matched like in haskell (http://www.haskell.org/tutorial/patterns.html). Imagine, for example, how TMP code such as MPL and Boost libraries in general, will benefit from actually having it interpreted by the formalized compile time interpreter. 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. Such would give dramatic improvements in parse/compile time. Regards, -- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net