www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20071] New: ref locals

https://issues.dlang.org/show_bug.cgi?id=20071

          Issue ID: 20071
           Summary: ref locals
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: turkeyman gmail.com

It's frustrating that we can only use `ref` for function arguments. I should be
able to declare a local variable ref to capture the result of a ref function,
or to simplify a long expression.

ref int fun();

void test()
{
  ref int refLocal = fun();
  ref int resolveExpression = thing[10].something().member.x;
}


It feels very lame to use pointers in these cases.
It may also change semantics of assignment expressions when using pointers.

--
Jul 21 2019