[Issue 12872] New: Feature request: Allow ref in arguments at the callsite

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Jun 6 14:25:41 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=12872

          Issue ID: 12872
           Summary: Feature request: Allow ref in arguments at the
                    callsite
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: eco at gnuk.net

It'd be nice to be able to do this...

  void foo(ref int a)
  {
    a += 1;
  }

  void main()
  {
    int a;
    foo(ref a) // <---- callsite ref
  }

...to show that a reference is being taken during that call and that the value
may change within the function call.

I think it would also be nice if you could require the callsite ref using a
compiler switch and that it would eventually be on by default (I suspect this
is far more controversial though and should be considered a separate request
from just allowing the "ref" in the call).

The same extends to "out". "in" could be added too but I don't see much value
in that.

--


More information about the Digitalmars-d-bugs mailing list