On Wednesday, 17 December 2025 at 00:13:42 UTC, Richard (Rikki) Andrew Cattermole wrote:
[...]
string genStuff(string val) {
    return val ~ ";";
}

void myFunc() {
    mixin(genStuff("this"));
}
[...]
This won't work without a way to mark `genStuff` as CTFE only. Which doesn't exist currently.

Compiler has to know that a given execution context is CTFE only otherwise disallowed.

1. Any proposals to mark a function as CTFE only?

No, this is something that should've been done a while back.

The main concern is that you can get a linker error if you don't emit a function that was called.

Actually, in your example, don't see the problem.
'mixin' operates to provide text to the compiler _prior to_ run time. Therefore, even if 'genStuff()' has a run-time (as well as) compile-time meaning, the use of mixin should force the compile-time meaning to be taken.
So no ambiguity?
DL
  • Do string mixins... DLearner via Digitalmars-d-learn
    • Re: Do stri... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
      • Re: Do ... DLearner via Digitalmars-d-learn
        • Re:... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
          • ... DLearner via Digitalmars-d-learn
            • ... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
              • ... DLearner via Digitalmars-d-learn
        • Re:... Adam D. Ruppe via Digitalmars-d-learn
          • ... DLearner via Digitalmars-d-learn
    • Re: Do stri... Kapendev via Digitalmars-d-learn

Reply via email to