On 03/17/2015 11:14 AM, Jonathan M Davis via Digitalmars-d-learn wrote:

> Or, take this example which (unfortunately) currently compiles:
>
> ref int getBar(ref int bar) @safe
> {
>      return bar;
> }
>
> ref int getFoo() @safe
> {
>      int foo;
>      return getBar(foo);
> }
>
> void main()
> {
>      getFoo() = 7;
> }

[...]

> I believe that the return attribute stuff that was recently added is
> intended to solve these issues

Yes, it is available on git head (and works without @safe):

ref int getBar(return ref int bar) @safe    // <-- Add 'return'
{
     return bar;
}

ref int getFoo() @safe
{
     int foo;
     return getBar(foo);    // <-- Does not compile anymore
}

> so I'm not very familiar with the details.

I think there are corner cases that even the 'return' attribute does not solve but I did not follow those discussions.

Ali

Reply via email to