[Issue 809] Should be possible to convert lazy argument to delegate

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jun 4 15:27:13 UTC 2019


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

Andrei Alexandrescu <andrei at erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrei at erdani.com

--- Comment #8 from Andrei Alexandrescu <andrei at erdani.com> ---
On the face of it, a lazy parameter is a delegate so the request makes sense.
On the other hand lazy T is meant to be "pretty much the same as T". This works
today:

void test(lazy int dg){
    int delegate() dg_ = { return dg; };
}

I'm not sure how it interacts with attributes and qualifiers.

This could be made to work:

void test(lazy int dg){
    int delegate() dg_ = &dg;
}

Currently, oddly enough (and definitely a bug), this issues an unfit error
message:

void test(lazy int dg){
    auto x = &dg;
}

"Error: lazy variable dg cannot be modified" :o)

So it seems like taking the address of a lazy is "available" and could return
the underlying delegate.

--


More information about the Digitalmars-d-bugs mailing list