How to avoid ctRegex (solved)
    ag0aep6g via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Sat Aug 27 11:07:07 PDT 2016
    
    
  
On 08/27/2016 07:35 PM, cy wrote:
> When I saw `auto a = b;` at the module level, I thought that b had to be
> something you could evaluate at compile time.
That's right.
> But I guess it can be a
> runtime calculated value, acting like it was assigned in a a static
> this() clause,
No, that's not right. The initializer for a module level variable has to 
be a compile-time constant.
If the initializer is a function call, the compiler attempts to evaluate 
it at compile time. We have an acronym for that: CTFE = Compile Time 
Function Evaluation. `regex("foobar")` can be evaluated that way, so it 
can be used as an initializer for a module level variable.
    
    
More information about the Digitalmars-d-learn
mailing list