[Issue 13494] New: Allow setting delegate member variables to do-nothing stub
    via Digitalmars-d-bugs 
    digitalmars-d-bugs at puremagic.com
       
    Thu Sep 18 11:45:18 PDT 2014
    
    
  
https://issues.dlang.org/show_bug.cgi?id=13494
          Issue ID: 13494
           Summary: Allow setting delegate member variables to do-nothing
                    stub
           Product: D
           Version: D2
          Hardware: x86
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: hsteoh at quickfur.ath.cx
There should be a way to set the default value of a delegate member variable to
point to a do-nothing stub delegate that simply does nothing:
-----
struct S {
    void delegate(dchar) dg = (dchar) {};
}
-----
Currently there is no way to do this, because (1) the compiler doesn't know
that the context pointer is actually unused and therefore can be set to null;
(2) the compiler appears to be unable to generate code for S.init because it
requires resolving the link-time address of the do-nothing delegate's body at
compile-time. Both problems are solvable ((1): data flow analysis ought to
reveal independence from context-pointer; (2): relocation entries should be
generated where the .init value is used, so that the linker can fill in the
address of the stub delegate).
--
    
    
More information about the Digitalmars-d-bugs
mailing list