[Issue 6442] New: Allow for passing values with the 'ref' keyword

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Aug 6 04:50:19 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=6442

           Summary: Allow for passing values with the 'ref' keyword
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: wfunction at hotmail.com


--- Comment #0 from wfunction at hotmail.com 2011-08-06 04:50:10 PDT ---
It would be AWESOME if you could pass by-ref parameters using the ref keyword
(ditto with 'out'):


    void foo(ref int bar) { ... }
    int i = 0;
    foo(ref i);   // <------- here

and

    void foo(out int bar) { ... }
    int i = 0;
    foo(out i);   // <------- here


This should be an _optional_ feature, to avoid breaking code and to aide with
generics (saying 'ref' should, however, REQUIRE that the parameter be passed by
ref).

Why?

Documentation.

It documents the fact that you're passing something by reference, avoids bugs
where the variable is changed to be passed by value and the caller's code no
longer works, and making it optional allows everything to still work as before.

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


More information about the Digitalmars-d-bugs mailing list