Thread overview
[Issue 8121] New: "scope ref" is perfectly OK
Jul 20, 2012
Matthias Walter
Aug 28, 2013
Andrej Mitrovic
May 19, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8121

           Summary: "scope ref" is perfectly OK
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: wfunction@hotmail.com


--- Comment #0 from wfunction@hotmail.com 2012-05-19 12:27:00 PDT ---
void test(scope ref int) { }
void main() { }

There is nothing wrong with passing something by reference with 'scope', so DMD should compile this.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 19, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8121



--- Comment #1 from wfunction@hotmail.com 2012-05-19 12:29:43 PDT ---
Also, "scope out" (and even "scope lazy") should also work, since it is perfectly valid for both of them to say, "this parameter will not be escaped".

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 20, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8121


Matthias Walter <xammy@xammy.info> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |xammy@xammy.info


--- Comment #2 from Matthias Walter <xammy@xammy.info> 2012-07-19 23:58:04 PDT ---
Does this bug report also cover the case of *returning* scope ref in order to make the following possible:

scope ref T opIndex(...);

For example in std.container.Array this is helpful in order to write

array[0].method()

because for by-value opIndex the method() is called on a *copy* of the first
element!

On the other hand returning by (the usual) ref prevents the container from being a 'sealed container' and hence the restriction would say:

"opIndex returns by reference but this reference may not be escaped but only be used to call a method (including operators) on the returned object."

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 20, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8121



--- Comment #3 from wfunction@hotmail.com 2012-07-20 00:50:30 PDT ---
That doesn't make much sense to me... I mean, I agree we need to be able to return scoped values, but given that scope is a storage class, I don't think applying it to a return type makes sense.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 28, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=8121


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich@gmail.com


--- Comment #4 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-08-28 15:31:50 PDT ---
*** Issue 10917 has been marked as a duplicate of this issue. ***

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