On Wednesday, 9 February 2022 at 16:37:22 UTC, Ali Çehreli wrote:
On 2/9/22 01:07, bauss wrote:

> It will not run at compile-time because csvText is a runtime
variable.
> It should be enum to be accessible at compile-time.

Yes. For the sake of completeness, any expression needed at compile time will be (attempted to be) executed at compile time. For example, an expression used as a template parameter will be executed at compile time as well.

> The append operation
> will be executed at runtime, which means that even if the
loop runs at
> compile-time then you're effectively not winning anything and
it
> basically just becomes a loop-unroll manually done.

That's not true. It all depends on how the expression is needed. If for example, the variable were defined as enum, the compiler had to execute the code at compile time to compute its value.

> The solution would be to create a function that returns a
string [...]
> And then simply using mixin

That is unnecessary and hurts readability. :/ Most programmers see string mixins as a last resort.

In any case, some people may find a compile-time file parsing example that I included in a presentation:

  https://youtu.be/dRORNQIB2wA?t=3157

Ali

Thank you Ali for the clarifications

Reply via email to