Executing pure D at compile-time - Someone needs to write a D interpreter using templates!

Chad J gamerChad at _spamIsBad_gmail.com
Thu Feb 8 12:41:08 PST 2007


kris wrote:
...
> 
> Thoughts?
> 
> - Kris
> 
> 

Hmmm, why doesn't someone write a D interpreter using templates?

Then it could work like this:

template createAConstant( char[] args )
{
	const int createAConstant =
		execute!("

		import std.math;

		int main( char[] args )
		{
			// maybe do something with args
			return std.math.PI;
		}

		", args);
}

It seems very daunting since, well, damn it just is.  But we can 
bootstrap it.  Just implement a small, turing complete, amount of D 
using templates.  Then you can write a large part of the interpreter 
using the D code that the templates implemented.  Then you could write 
an even larger part in the D that the small-D implemented.  Ultimately 
it would be cool if the D front end shared a lot of the same D code as 
the compile-time interpreter, which would help adoption of new features.



More information about the Digitalmars-d mailing list