Issue 10557 - __traits(== __parameters) should accept function pointer/delegate type
Summary: __traits(== __parameters) should accept function pointer/delegate type
Status: RESOLVED WONTFIX
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 enhancement
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2013-07-06 07:30 UTC by Kenji Hara
Modified: 2013-07-07 05:57 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Kenji Hara 2013-07-06 07:30:42 UTC
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 2 Kenji Hara 2013-07-07 05:57:46 UTC
After bug 10548 fixed, this ER would become unnecessary. So I withdraw this.