[Issue 8121] "scope ref" is perfectly OK

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jul 19 23:58:11 PDT 2012


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


Matthias Walter <xammy at xammy.info> changed:

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


--- Comment #2 from Matthias Walter <xammy at 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: -------


More information about the Digitalmars-d-bugs mailing list