On Monday, 26 July 2021 at 12:01:23 UTC, Adam D Ruppe wrote:
On Monday, 26 July 2021 at 11:43:56 UTC, workman wrote:
__FILE__[0..$]
Why do you have that [0..$] there? It is probably breaking the
__FILE__ magic.
Correct.
The compiler has to evaluate the default argument as constant
expression in order to use it as default value..
Therefore it evaluates (__FILE__)[0 ..$]you first eval __FILE__
at CTFE within the module you are defining the function in.
And then you slice it from zero to length.
On the other hand if you use x = __FILE__ it recognizes that as a
special constant expression which can be put into the callsite
directly.