On 08/04/2024 10:45 AM, Liam McGillivray wrote:
On Sunday, 7 April 2024 at 08:59:55 UTC, Richard (Rikki) Andrew Cattermole wrote:
Unfortunately runtime and CTFE are the same target in the compiler.

:-(
Will this ever be changed?

A tad unlikely, it would be a rather large change architecturally to dmd.

```d
template Foo(Args) {
    enum Foo = () {
        return Args.init;
    }();
}
```

Something like that should work instead.

I'm sorry, but I can't comprehend any of your example. What would be fed into `Args`? I don't understand how this works, or how I would use it for what I want.

You would replace it with whatever template parameters you want (including nothing). It's there as a place holder.

Same for the return on the closure.

But the main thing to understand is that the closure that gives the enum a value, that'll be CTFE only, no runtime target.
  • "Error: `Ty... Liam McGillivray via Digitalmars-d-learn
    • Re: "E... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
      • Re: &qu... Liam McGillivray via Digitalmars-d-learn
        • Re:... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
          • ... Liam McGillivray via Digitalmars-d-learn
            • ... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
              • ... Liam McGillivray via Digitalmars-d-learn
                • ... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
                • ... Liam McGillivray via Digitalmars-d-learn
                • ... Steven Schveighoffer via Digitalmars-d-learn
                • ... Liam McGillivray via Digitalmars-d-learn
                • ... Steven Schveighoffer via Digitalmars-d-learn
                • ... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
      • Re: &qu... Liam McGillivray via Digitalmars-d-learn

Reply via email to