| |
| Posted by Steven Schveighoffer in reply to Stefan Koch | PermalinkReply |
|
Steven Schveighoffer
Posted in reply to Stefan Koch
| 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
|