www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Write file at compile time?

reply Inquie <Inquie data.com> writes:
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?
Apr 02
next sibling parent Basile B. <b2.temp gmx.com> writes:
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.
Apr 02
prev sibling parent reply Meta <jared771 gmail.com> writes:
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.
Apr 03
parent reply Inquie <Inquie data.com> writes:
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.
Apr 03
next sibling parent reply Stefan Koch <uplink.coder googlemail.com> writes:
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.
Apr 03
parent Stefan Koch <uplink.coder googlemail.com> writes:
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
Apr 03
prev sibling parent reply Adam D. Ruppe <destructionator gmail.com> writes:
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.
Apr 03
parent reply Inquie <Inquie data.com> writes:
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.
Apr 03
parent Stefan Koch <uplink.coder googlemail.com> writes:
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.
Apr 04