[Issue 11602] New: `delegate`s passed with `in` direction causes closures

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Nov 25 06:38:53 PST 2013


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 at puremagic.com
        ReportedBy: verylonglogin.reg at gmail.com


--- Comment #0 from Denis Shelomovskij <verylonglogin.reg at gmail.com> 2013-11-25 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: -------


More information about the Digitalmars-d-bugs mailing list