Writing/Creating files at compile-time

ketmar via Digitalmars-d digitalmars-d at puremagic.com
Sun Aug 9 18:57:40 PDT 2015


On Sun, 09 Aug 2015 09:07:49 +0000, 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.

next will be full filesystem access, 'cause hey, we need directory 
listings! and stat()! and unlink()! and wow, how can we live without http 
downloader?! and...

this road has no end, and the problem already has a solution: 
preprocessing step. nothing stops you from writing your preprocessors in 
D and run 'em as a part of your build script.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20150810/7608c701/attachment.sig>


More information about the Digitalmars-d mailing list