Bug 10557 – __traits(== __parameters) should accept function pointer/delegate type

Status
RESOLVED
Resolution
WONTFIX
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-07-06T07:30:00Z
Last change time
2013-07-07T05:57:46Z
Keywords
pull
Assigned to
nobody
Creator
k.hara.pg

Comments

Comment #0 by k.hara.pg — 2013-07-06T07:30:42Z
Recent function type and default argument improvement: https://github.com/D-Programming-Language/dmd/pull/1102 changes default arguments and parameter identifiers "volatile" on function type. The change itself makes sense, but after all, we cannot take the information from function pointer/delegate variable and function literal symbol anymore. void function(int arg = 10) fp; pragma(msg, typeof(fp)); // prints void function(int arg = 10) static if (is(typeof(fp) FP == F*, F)) { pragma(msg, F); // print void(int) static if (is(F PT == __parameters)) { // Right now here, PT does not contain any def-arg and param-id informations. pragma(msg, PT); // prints (int) } } This is expected behavior, but it is also inconvenient for some meta-programming. To get the volatile information, I'd like to propose that is(F PT == __parameters) accepts function pointer type and delegate type directly. void function(int a = 10) fp; static if (is(typeof(fp) PT1 == __parameters)) { // Currently this always fails, but will pass after this ER is implemented pragma(msg, PT1); // will print (int a = 10) } void delegate(int b = 20) dg; static if (is(typeof(dg) PT2 == __parameters)) { // Currently this always fails, but will pass after this ER is implemented pragma(msg, PT2); // will print (int b = 20) }
Comment #1 by k.hara.pg — 2013-07-06T07:42:51Z
Comment #2 by k.hara.pg — 2013-07-07T05:57:46Z
After bug 10548 fixed, this ER would become unnecessary. So I withdraw this.