Another way to do CTFE

Araq via Digitalmars-d digitalmars-d at puremagic.com
Tue Jun 17 15:12:18 PDT 2014


On Tuesday, 17 June 2014 at 19:41:59 UTC, Ary Borenszweig wrote:
> CTFE is really nice but has its limitations: you can't do 
> anything you want, and since it's interpreted it requires an 
> interpreter and it's generally slow. Nimrod does the same 
> thing, and now they are implementing a VM to run the 
> interpreted code faster. Is this really the way to go?
>

For your information the new VM shipped with 0.9.4 and runs
Nimrod code faster at compile-time than Python runs code at
run-time in the tests that I did with it. :-) That said, it
turned out to be much harder to implement than I thought and I
wouldn't do it again.

> ...
> The compiler could be smart and cache the executable so that 
> anytime it has to expand it it just needs to invoke it (skip 
> the compile phase).
>
> What do you think?
>

It is a *very* good idea and this is exactly the way I would do
it now. However, you usually only trade one set of problems for
another. (For instance, giving Nimrod an 'eval' module is now
quite easy to do...)


More information about the Digitalmars-d mailing list