www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18825] New: No syntax for function literal returning a

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

          Issue ID: 18825
           Summary: No syntax for function literal returning a reference
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: jl leroy.nyc

Consider:

int global;

int foo()
{
  return global;
}

As per the doc, this is equivalent to:

auto foo = function int() {
  return global;
};

But it is not possible to create a function literal equivalent to this:

ref int foo()
{
  return global;
}

I tried placing the ref everywhere it makes sense, to no avail.

--
May 04 2018