Concern about the ref return argument and scope

Manu via Digitalmars-d digitalmars-d at puremagic.com
Tue Jan 27 23:04:33 PST 2015


On 28 January 2015 at 14:57, deadalnix via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
> We are going to introduce 2 features that basically are 2 hacks working
> around the same problem : lifetime.
>
> It may sound like any of these is useful and progress, and somehow it is,
> but that is going to create many feature for underpowered capabilities.
>
> This is this kind of situation where simple and easy collide.
>
> I'd suggest we get a proper lifetime management. For ref return, we can
> still make it safe by defining the lifetime of the ref return as the
> intersection of the lifetime of the ref parameters and call it a day. As far
> as I can tell, this cover the vast majority of cases.

Lifetime 'this' probably also needs to exist, for objects that return
members by ref.
I think this covers practically all useful cases. What problem cases
remain? Returning a global by ref?
I should think that can also be supported easily enough; return by ref
without lifetime implies global lifetime, and the function would
compile error when trying to return a local/member/argument that way.

I agree with you. I'm completely unsatisfied with the current
proposals, or 'plans', as I think they have been promoted.


More information about the Digitalmars-d mailing list