[Issue 12664] @nogc for lazy arguments too

2014-04-27 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=12664

Sobirari Muhomori dfj1es...@sneakemail.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |INVALID

--- Comment #1 from Sobirari Muhomori dfj1es...@sneakemail.com ---
The third example can't infer attributes because it doesn't create the
delegate, and can't accept arbitrary type info because it's not templated.

--


[Issue 12664] @nogc for lazy arguments too

2014-04-27 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=12664

--- Comment #2 from bearophile_h...@eml.cc ---
(In reply to Sobirari Muhomori from comment #1)

 The third example can't infer attributes because it doesn't create the
 delegate, and can't accept arbitrary type info because it's not templated.

Thank you, I understand now :-)

Is it a good idea to allow annotations for lazy arguments?

void foo(T)(lazy @nogc x) @nogc {
auto r = x();
}
void main() {
foo(1);
}


I guess lazy arguments are not used commonly enough to deserve such
improvements.

--


[Issue 12664] @nogc for lazy arguments too

2014-04-27 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=12664

--- Comment #3 from bearophile_h...@eml.cc ---
(In reply to bearophile_hugs from comment #2)

 void foo(T)(lazy @nogc x) @nogc {
 auto r = x();
 }
 void main() {
 foo(1);
 }

Sorry, I meant to write:

void foo(lazy @nogc x) @nogc {

--


[Issue 12664] @nogc for lazy arguments too

2014-04-27 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=12664

--- Comment #4 from Sobirari Muhomori dfj1es...@sneakemail.com ---
Yes, annotation could do the trick.

--


[Issue 12664] @nogc for lazy arguments too

2014-04-27 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=12664

Kenji Hara k.hara...@gmail.com changed:

   What|Removed |Added

 Resolution|INVALID |DUPLICATE

--- Comment #5 from Kenji Hara k.hara...@gmail.com ---
Lazy argument is implicitly converted to scope local delegate. And the
original argument @safe-ty and purity are implicitly treated as they belong to
the caller side.

int foo(lazy int x) pure @safe { return x(); }

int get() { return 1; }  // impure un@safe

void main()
{
foo(get());  // OK!
}

So I think that nothrow-ness and @nogc-ability should be treated as same.

*** This issue has been marked as a duplicate of issue 12647 ***

--