Filling an array at compile time
jj_1337 at live.dk
Thu Feb 10 07:16:13 UTC 2022
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
> > 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
> > 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
> > 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:
Thank you Ali for the clarifications
More information about the Digitalmars-d-learn