[Issue 8065] New: No way to write function/delegate literals returning ref T

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue May 8 03:40:59 PDT 2012


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 at puremagic.com
        ReportedBy: gasper.azman at gmail.com


--- Comment #0 from Gašper Ažman <gasper.azman at gmail.com> 2012-05-08 03:42:20 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
properly, so this bug depends on #8064.

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


More information about the Digitalmars-d-bugs mailing list