Writing/Creating files at compile-time

Iain Buclaw via Digitalmars-d digitalmars-d at puremagic.com
Mon Aug 10 02:55:40 PDT 2015


On 10 August 2015 at 10:59, via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
> On Monday, 10 August 2015 at 08:03:47 UTC, lobo wrote:
>>
>> While I agree with you I am curious; where would the compiler place its
>> artefacts and why can't "export" write to the same place?
>
>
> I think that is an implementation detail and not a language-issue.
>
>> The way I see it files created by export would be transient anyway,
>> generated each time you compile.
>
>
> Yes, or cached, but it should not be a file. You might want the ability to
> build resources (e.g. for Apple ios/osx bundles), but then you would need
> compiler support for those resource bundles. E.g. create a bundle as a
> "database" and then populate it programatically.
>
> If you go down the route of generating files you probably also would also
> need to build in "make" like dependency resolution so that the resources are
> built in the correct order...
>
> Another point: if "export" is needed to generate D-files then one would be
> better off adding AST-macros instead and generate the AST for whole modules
> in-memory. Saving the AST to disk for inspection would be a compiler-pragma.
>

Who said anything about D-files?  import() accepts any arbitrary text
that you may want to embed in a program.


More information about the Digitalmars-d mailing list