Extracting user defined attributes on function parameters

Adam D. Ruppe destructionator at gmail.com
Fri Apr 17 17:48:06 UTC 2020


On Friday, 17 April 2020 at 17:31:32 UTC, Jean-Louis Leroy wrote:
> Well, can't do. I need this purely at compile time, and 
> cross-module.

And the CTFE engine gets weird with it too.... dmd will have to 
fix this.

But default parameters might not be possible in general at CT 
anyway... it is actually possible to define it to a variable. 
Observe:

int a;

void f(int arg = a) { // default arg is to use the global...
         import std.stdio; writeln(arg);
}

void main() {
         f(); // 0 this time
         a = 4; // and it can be changed at runtime!
         f(); // will now say 4
}



More information about the Digitalmars-d-learn mailing list