[Issue 10557] New: __traits(== __parameters) should accept function pointer/delegate type

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jul 6 07:30:43 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10557

           Summary: __traits(== __parameters) should accept function
                    pointer/delegate type
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: k.hara.pg at gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg at gmail.com> 2013-07-06 07:30:42 PDT ---
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)
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list