__FILE__
Steven Schveighoffer
schveiguy at gmail.com
Thu Aug 5 02:17:32 UTC 2021
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
More information about the Digitalmars-d-learn
mailing list