DIP81: Writing files at compile time

Tofu Ninja via Digitalmars-d digitalmars-d at puremagic.com
Wed Aug 12 18:02:56 PDT 2015


On Thursday, 13 August 2015 at 00:58:14 UTC, JDemler wrote:
> On Wednesday, 12 August 2015 at 23:27:16 UTC, Tofu Ninja wrote:
>> On Wednesday, 12 August 2015 at 18:37:40 UTC, JDemler wrote:
>>> Triggered by the original forum thread I wrote a DIP to 
>>> further explain the idea of the writing files at compile time 
>>> feature and its implications.
>>>
>>> http://wiki.dlang.org/DIP81
>>>
>>> Please discuss!
>>
>> The benefits of this I see are debugging, actually having the 
>> generated files makes it much simpler to see what is going 
>> wrong. Otherwise the utility of this can be achieved with 
>> string mixins.
>>
>> A simple alternative to this would be a flag to the compiler 
>> to expand mixins and output the new files. This would also be 
>> great for tooling, an IDE could use this and allow you to 
>> expand a mixin in place to see what it looks like. And 
>> currently all the auto complete engines I have seen for D 
>> don't handle mixins very well. Expanding them would make 
>> autocompletion a simpler job.
>
> While this might work for very simple and basic mixins, with 
> the combination of TMP and compile time reflection this becomes 
> not only impractical but also impossible.
>
> Think again about the vibe.d example:
> There is one mixin handeling all the template-type combinations.
> How would such a mixin be expanded? The resulting code differs 
> from template to template and from type to type.

I suppose such an expansion flag would need to expand templates 
as well, which is still not a bad idea. Templates can be hard to 
follow sometimes and expanding them out in all their forms could 
be helpful for debugging and for tooling as well. Though there 
would be a lot of expansions.


More information about the Digitalmars-d mailing list