www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13494] New: Allow setting delegate member variables to


          Issue ID: 13494
           Summary: Allow setting delegate member variables to do-nothing
           Product: D
           Version: D2
          Hardware: x86
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: hsteoh 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).

Sep 18 2014