Re: mixin under -betterC

2023-12-09 Thread DLearner via Digitalmars-d-learn
On Sunday, 26 November 2023 at 15:35:39 UTC, Adam D Ruppe wrote: On Thursday, 23 November 2023 at 16:33:52 UTC, DLearner wrote: string mxnTest(string strVar1, string strVar2) { return `(int Var1, int Var2) { if (Var1 > Var2) { return true; } else { return false;

Re: mixin under -betterC

2023-11-26 Thread Basile B. via Digitalmars-d-learn
On Thursday, 23 November 2023 at 16:33:52 UTC, DLearner wrote: Code below is intended to test simple mixin with lambda function under -betterC. Works with full-D, but fails with 'needs GC' errors under -betterC. Why is this so, bearing in mind the concatenations are executed at compile, not

Re: mixin under -betterC

2023-11-26 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 23 November 2023 at 16:33:52 UTC, DLearner wrote: string mxnTest(string strVar1, string strVar2) { return `(int Var1, int Var2) { if (Var1 > Var2) { return true; } else { return false; } }(` ~ strVar1 ~ `,` ~ strVar2 ~ `)`; } ``` This

Re: mixin under -betterC

2023-11-26 Thread DLearner via Digitalmars-d-learn
On Thursday, 23 November 2023 at 17:02:58 UTC, Paul Backus wrote: [...] This is a known limitation: https://issues.dlang.org/show_bug.cgi?id=23637 [...] Sorry to come back to this, but the reference above suggests _not_ a bug in the compiler. If not a bug in the compiler, please, what is

Re: mixin under -betterC

2023-11-23 Thread DLearner via Digitalmars-d-learn
On Thursday, 23 November 2023 at 18:54:09 UTC, Julian Fondren wrote: [...] The `enum` answer? [...] No, the 'template' answer. To me, if the 'template' suggestion worked (as it did), then my simple mixin (as in my original post) should also work.

Re: mixin under -betterC

2023-11-23 Thread Julian Fondren via Digitalmars-d-learn
On Thursday, 23 November 2023 at 17:46:55 UTC, DLearner wrote: I just find it surprising that your suggestion worked, but the (slightly simpler) earlier version did not. The `enum` answer? That also works, but you have to make a change at the callsite as well, to `mixin(mxnTest!("Var_A",

Re: mixin under -betterC

2023-11-23 Thread DLearner via Digitalmars-d-learn
On Thursday, 23 November 2023 at 17:03:29 UTC, Julian Fondren wrote: On Thursday, 23 November 2023 at 16:33:52 UTC, DLearner wrote: Why is this so, bearing in mind the concatenations are executed at compile, not run, time? If you compile without -betterC, it'll work, but if you examine the

Re: mixin under -betterC

2023-11-23 Thread Julian Fondren via Digitalmars-d-learn
On Thursday, 23 November 2023 at 16:33:52 UTC, DLearner wrote: Why is this so, bearing in mind the concatenations are executed at compile, not run, time? If you compile without -betterC, it'll work, but if you examine the result you'll find that the mxnTest function is still compiled into

Re: mixin under -betterC

2023-11-23 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 23 November 2023 at 16:33:52 UTC, DLearner wrote: Code below is intended to test simple mixin with lambda function under -betterC. Works with full-D, but fails with 'needs GC' errors under -betterC. Why is this so, bearing in mind the concatenations are executed at compile, not

mixin under -betterC

2023-11-23 Thread DLearner via Digitalmars-d-learn
Code below is intended to test simple mixin with lambda function under -betterC. Works with full-D, but fails with 'needs GC' errors under -betterC. Why is this so, bearing in mind the concatenations are executed at compile, not run, time? ``` // Test harness extern(C) void main() {