D interpreter

Bruce Adams tortoise_74 at yeah.who.co.uk
Wed Oct 24 17:42:59 PDT 2007


Jarrett Billingsley Wrote:

> "Bruce Adams" <tortoise_74 at yeah.who.co.uk> wrote in message 
> news:ffo90d$sgo$1 at digitalmars.com...
> > Hi,
> >   Seeing the link:
> >
> > http://www.d-programming-language.org/
> >
> > posted in another thread reminded me that DMD sports a nifty D 
> > interpreter. Something I always wanted for C++ incidentally. With all the 
> > talk on virtual machines recently I was wondering how the D interpreter 
> > works.
> >
> > Does it compile and run?  or use the embedded interpreter used for compile 
> > time evaluation? are these one and the same?
> >
> > What happens with imports? Are they interpreted or compiled on the fly or 
> > required to exist already?
> >
> > I know I should really try the experiment and find some of this out for 
> > myself.
> >
> > How hard would it be to duplicate this behaviour in the gdc front end?
> >
> 
> It's not so much an interpreter as it is const-folding on steroids.
> 
> The "interpreter" only works with a subset of language features.  Mostly, 
> non-member functions which don't use dynamic memory.  This is only used to 
> do CTFE.  In fact, go to the "functions" section of the spec, and at the 
> end, it explains all about CTFE and what's allowed/disallowed.
> 
> Nothing has to be done with GDC because DMD and GDC have exactly the same 
> frontend, they only differ in the backend (optimization and machine code 
> generation).  GDC has CTFE too. 
> 
I think you misunderstood the nature of my misunderstanding.
I hoped that the -run option of DMD might make it operate as an interpreter. It sounds like it does but only in the sense of compile then 
run the result which is half way there.
gdc doesn't have quite the same front end in that it use the gcc command line options (which I and my gnu loving kin prefer) but of course it does have the same compiler front end so everything you say about CTFE applies.

Regards,

Bruce.





More information about the Digitalmars-d mailing list