www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11602] New: `delegate`s passed with `in` direction causes closures

https://d.puremagic.com/issues/show_bug.cgi?id=11602

           Summary: `delegate`s passed with `in` direction causes closures
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: performance
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: verylonglogin.reg gmail.com



18:38:51 MSK ---
According to specs "`in` equivalent to `const scope`" but the following code
allocates a closure:
---
import std.stdio;

// change direction to `scope` to leave `i` on stack
void f(in void delegate() del)
{ del(); }

void main()
{
    int i, j;
    writeln(&j); // show stack address
    f(() => writeln(&i)); // `i` is on heap
}
---

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