DIP81: Writing files at compile time

Rikki Cattermole via Digitalmars-d digitalmars-d at puremagic.com
Thu Aug 13 01:11:39 PDT 2015


On 13/08/2015 7:57 p.m., JDemler wrote:
> On Thursday, 13 August 2015 at 04:58:06 UTC, Rikki Cattermole wrote:
>> [...]
>
> So in the vibe.d example we would generate a file diet.di which would
> include all the generated diet templates of the whole project? Maybe 100
> * 50 extra lines of code for a medium sized project?
> This is not debuggable, understandable or transparent.
> Especially because the generated code lies inside a file of a library
> which I should not need to know about.

If it is done via D interface files, you would be in control of where it 
lands. It would not go into a dub package directory that you do not 
control for your project.

You want it to be debuggable, this is. Is it nice and pretty? No.
If you are interested in only one code path i.e. specific template 
arguments to outputted and not the others, then perhaps a pragma can be 
used to limit it.

> Also I do not understand how we could expand template instatiations.
> Maybe it would be possible for basic templates that only take types but
> imagine a template that takes a parse tree as a value. How would an
> expanded version of that look like?

Template if statement. Also argument overloads.

Also remember, the information must exist to expand it. If it didn't, we 
sure couldn't generate assembly.


More information about the Digitalmars-d mailing list