Writing/Creating files at compile-time

Rikki Cattermole via Digitalmars-d digitalmars-d at puremagic.com
Sun Aug 9 07:00:53 PDT 2015


On 10/08/2015 1:57 a.m., cym13 wrote:
> On Sunday, 9 August 2015 at 13:51:21 UTC, Andrei Alexandrescu wrote:
>> On 8/9/15 5:07 AM, JDemler wrote:
>>> We can read files at compile-time:
>>>
>>>    enum file = import(fileName);
>>>
>>> But we cannot write to a file or create files at compile time.
>>>
>>> Generating code at compile-time and mixing it in is fun but has a few
>>> flaws.
>>> It isn't debuggable, the generated code cannot be directly inspected (we
>>> have to use pragma(msg, )) and it is not possible to manually tweak it.
>>>
>>> If we could generate source files (.d) at compile time and then import
>>> them using mixins or something else, these problems can be dealt with.
>>
>> I think this is an interesting pursuit that closes the circle on a
>> number of issues, such as debuggability and compilation speed of mixin
>> code. -- Andrei
>
> The moment this is added to D, we will have two complete languages in
> one: an interpreted one at compile-time and another at runtime.
>
> While I find this interesting, I wonder wether this is  a good idea or not.

I'm actually at the point where I believe the addition of string import 
was a bad one. No. I prefer preprocessing into a D file first.
It irks me, you have to be pretty careful with them, but at least a 
preprocessed file you know _exactly_ where all files need to be for CT.


More information about the Digitalmars-d mailing list