Re: Expanding CTFE code during compilation

2022-07-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/23/22 2:27 PM, Azi Hassan wrote: On Saturday, 23 July 2022 at 00:56:39 UTC, Steven Schveighoffer wrote: On 7/22/22 3:22 PM, Azi Hassan wrote: Oh, interesting syntax. I was thinking something along the lines of ```D template printEnum(...) { version(debug) { ... // everythin

Re: Expanding CTFE code during compilation

2022-07-23 Thread Azi Hassan via Digitalmars-d-learn
On Saturday, 23 July 2022 at 00:56:39 UTC, Steven Schveighoffer wrote: On 7/22/22 3:22 PM, Azi Hassan wrote: Oh, interesting syntax. I was thinking something along the lines of ```D template printEnum(...) {     version(debug) {     ... // everything we already did     } else {   

Re: Expanding CTFE code during compilation

2022-07-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/22/22 3:22 PM, Azi Hassan wrote: Oh, interesting syntax. I was thinking something along the lines of ```D template printEnum(...) {     version(debug) {     ... // everything we already did     } else {     enum printEnum(alias x) = x;     } } ``` But I like yours better. `

Re: Expanding CTFE code during compilation

2022-07-22 Thread Azi Hassan via Digitalmars-d-learn
On Wednesday, 20 July 2022 at 14:11:52 UTC, Dennis wrote: On Wednesday, 20 July 2022 at 00:33:06 UTC, Azi Hassan wrote: Where did you find it though ? I checked dmd --help and man dmd before making this thread, but to no avail. It was implemented as an internal debugging tool, not a documente

Re: Expanding CTFE code during compilation

2022-07-22 Thread Azi Hassan via Digitalmars-d-learn
On Wednesday, 20 July 2022 at 01:15:44 UTC, Steven Schveighoffer wrote: On 7/19/22 8:57 PM, Steven Schveighoffer wrote: There's a slight bloat in the compiler symbol table when  but other than that it should be effective. Obviously I didn't finish that thought... "when `-debug` isn't used on

Re: Expanding CTFE code during compilation

2022-07-20 Thread Dennis via Digitalmars-d-learn
On Wednesday, 20 July 2022 at 00:33:06 UTC, Azi Hassan wrote: Where did you find it though ? I checked dmd --help and man dmd before making this thread, but to no avail. It was implemented as an internal debugging tool, not a documented feature: https://github.com/dlang/dmd/pull/6556 It turn

Re: Expanding CTFE code during compilation

2022-07-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/19/22 8:57 PM, Steven Schveighoffer wrote: There's a slight bloat in the compiler symbol table when  but other than that it should be effective. Obviously I didn't finish that thought... "when `-debug` isn't used on the command line" -Steve

Re: Expanding CTFE code during compilation

2022-07-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/19/22 8:33 PM, Azi Hassan wrote: Nice, a compile time console.log. Thanks a lot, this will come in handy. I wonder if it can be combined with version(debug) to only run the pragma line if compiled with -g, this way we can keep the printEnum! line as it is. Then again, the code would beco

Re: Expanding CTFE code during compilation

2022-07-19 Thread Azi Hassan via Digitalmars-d-learn
On Tuesday, 19 July 2022 at 22:41:43 UTC, Steven Schveighoffer wrote: On 7/19/22 5:43 PM, Azi Hassan wrote: Just in case this is a consequence of the XY problem, the reason why I'm looking for this is to make sure that the code I wrote did evaluate to what I'm expecting it to. Right now I do

Re: Expanding CTFE code during compilation

2022-07-19 Thread Azi Hassan via Digitalmars-d-learn
On Tuesday, 19 July 2022 at 22:27:56 UTC, Dennis wrote: On Tuesday, 19 July 2022 at 21:43:01 UTC, Azi Hassan wrote: I'm wondering if the offers has the option of executing the parts that can be evaluated at compile time and then replacing them with the result of this evaluation. Try the `-vcg

Re: Expanding CTFE code during compilation

2022-07-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/19/22 5:43 PM, Azi Hassan wrote: Just in case this is a consequence of the XY problem, the reason why I'm looking for this is to make sure that the code I wrote did evaluate to what I'm expecting it to. Right now I do this with an enum assignment followed by static asserts, but I'd love i

Re: Expanding CTFE code during compilation

2022-07-19 Thread Dennis via Digitalmars-d-learn
On Tuesday, 19 July 2022 at 21:43:01 UTC, Azi Hassan wrote: I'm wondering if the offers has the option of executing the parts that can be evaluated at compile time and then replacing them with the result of this evaluation. Try the `-vcg-ast` flag: ```D import object; import std; void main() {

Expanding CTFE code during compilation

2022-07-19 Thread Azi Hassan via Digitalmars-d-learn
Hello, Apologies in advance if this has been asked before. I can't find the right words to express what I'm looking for, but essentially, I'm wondering if the offers has the option of executing the parts that can be evaluated at compile time and then replacing them with the result of this eva