Thread overview
Write file at compile time?
Apr 02, 2017
Inquie
Apr 02, 2017
Basile B.
Apr 03, 2017
Meta
Apr 03, 2017
Inquie
Apr 03, 2017
Stefan Koch
Apr 03, 2017
Stefan Koch
Apr 03, 2017
Adam D. Ruppe
Apr 03, 2017
Inquie
Apr 04, 2017
Stefan Koch
April 02, 2017
I would like to write the output of a manifest constant at compile time to a file instead of console using pragma(msg). Is this possible?


April 02, 2017
On Sunday, 2 April 2017 at 19:42:52 UTC, Inquie wrote:
> I would like to write the output of a manifest constant at compile time to a file instead of console using pragma(msg). Is this possible?

No.
April 03, 2017
On Sunday, 2 April 2017 at 19:42:52 UTC, Inquie wrote:
> I would like to write the output of a manifest constant at compile time to a file instead of console using pragma(msg). Is this possible?

D does not allow IO at compile time for security reasons.
April 03, 2017
On Monday, 3 April 2017 at 19:06:01 UTC, Meta wrote:
> On Sunday, 2 April 2017 at 19:42:52 UTC, Inquie wrote:
>> I would like to write the output of a manifest constant at compile time to a file instead of console using pragma(msg). Is this possible?
>
> D does not allow IO at compile time for security reasons.

what if I don't care about security reasons? I'm only needing it for developmental purposes.
April 03, 2017
On Monday, 3 April 2017 at 19:25:35 UTC, Inquie wrote:
> On Monday, 3 April 2017 at 19:06:01 UTC, Meta wrote:
>> On Sunday, 2 April 2017 at 19:42:52 UTC, Inquie wrote:
>>> I would like to write the output of a manifest constant at compile time to a file instead of console using pragma(msg). Is this possible?
>>
>> D does not allow IO at compile time for security reasons.
>
> what if I don't care about security reasons? I'm only needing it for developmental purposes.

there is --vcg-ast.
In the ~master version of dmd.

it gives you everything lowered and expanded.
given your code compiles.
April 03, 2017
On Monday, 3 April 2017 at 19:32:40 UTC, Stefan Koch wrote:
> On Monday, 3 April 2017 at 19:25:35 UTC, Inquie wrote:
>> On Monday, 3 April 2017 at 19:06:01 UTC, Meta wrote:
>>> On Sunday, 2 April 2017 at 19:42:52 UTC, Inquie wrote:
>>>> I would like to write the output of a manifest constant at compile time to a file instead of console using pragma(msg). Is this possible?
>>>
>>> D does not allow IO at compile time for security reasons.
>>
>> what if I don't care about security reasons? I'm only needing it for developmental purposes.
>
> there is --vcg-ast.
> In the ~master version of dmd.
>
> it gives you everything lowered and expanded.
> given your code compiles.

sorry -vcg-ast.
use it and look for {yourfilename}.cg
April 03, 2017
On Monday, 3 April 2017 at 19:25:35 UTC, Inquie wrote:
> what if I don't care about security reasons? I'm only needing it for developmental purposes.

Why does it have to be at compile time then? Just run an ordinary runtime program as part of your develop process; run a helper file in your makefile before compiling it.
April 03, 2017
On Monday, 3 April 2017 at 19:34:36 UTC, Adam D. Ruppe wrote:
> On Monday, 3 April 2017 at 19:25:35 UTC, Inquie wrote:
>> what if I don't care about security reasons? I'm only needing it for developmental purposes.
>
> Why does it have to be at compile time then? Just run an ordinary runtime program as part of your develop process; run a helper file in your makefile before compiling it.

Because it the code doesn't compile one has to copy and paste the pragma output to a d file and compile it to find the errors. It is useful to help debug mixins. Since D is pretty sorry at giving useful information for mixins it is easier to write the mixins out to disk in a d file then input them back in to the program. A simple static switch can alternate between the two. If we could output at compile time then we could

1. compile
2. flip switch
3. compile and get useful error messages

rather than

1. compile
2. copy pragma to do
3. flip switch
4. compile and get useful error messages

the pragma copy is, by far, the slowest step here and the others can be automated to basically happen in one step(although, I guess with some work one could automate the copying of the pragma too but it is not as robust).

Would be much easier to simply have the ability to write to disk instead of the console.



April 04, 2017
On Monday, 3 April 2017 at 21:20:41 UTC, Inquie wrote:
> On Monday, 3 April 2017 at 19:34:36 UTC, Adam D. Ruppe wrote:
>> [...]
>
> Because it the code doesn't compile one has to copy and paste the pragma output to a d file and compile it to find the errors. It is useful to help debug mixins. Since D is pretty sorry at giving useful information for mixins it is easier to write the mixins out to disk in a d file then input them back in to the program. A simple static switch can alternate between the two. If we could output at compile time then we could
>
> [...]

If you're fine with a custom dmd build, please open an issue on my dmd repo.