On 7/26/21 1:05 PM, Stefan Koch wrote:
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..

This is not true, you can use runtime calls as default values.

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.

This might be how it is implemented, but it shouldn't be. `__FILE__` should be usable inside any expression as a default value, which should expand to the call-site for the function (as usual).

But this has nothing to do with CTFE as far as I know.

-Steve
  • __FILE__ workman via Digitalmars-d-learn
    • Re: __FILE__ Adam D Ruppe via Digitalmars-d-learn
      • Re: __FILE__ Stefan Koch via Digitalmars-d-learn
        • Re: __FILE__ Steven Schveighoffer via Digitalmars-d-learn
          • Re: __FILE__ Ali Çehreli via Digitalmars-d-learn
            • Re: __F... Steven Schveighoffer via Digitalmars-d-learn
    • Re: __FILE__ Mathias LANG via Digitalmars-d-learn

Reply via email to