www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8065] New: No way to write function/delegate literals returning ref T

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

           Summary: No way to write function/delegate literals returning
                    ref T
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: gasper.azman gmail.com



PDT ---
Currently, I (with the help of #D on irc.freenode.net) couldn't find any way to
define a function or delegate literal returning a reference.

our best guess at the syntax was

delegate ref T (params) { body }

or, to be more general,

delegate ATTRIBUTE T (params) { body }

example:
void main() {
    auto bar = new int[5];
    auto foo = delegate ref int(size_t i) { return bar[i]; };
}

This example fails with the error "basic type expected, not ref".

Note: even if this did work, assigning functions returning ref does not work


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 08 2012