@nogc and lazy arguments
bearophile via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Apr 27 06:09:38 PDT 2014
Lazy arguments in general allocate, but who is to blame for the
allocation?
Isn't the allocation at the calling point?
This code:
void foo(lazy int x) @nogc {
auto r = x(); // Error
}
void main() {
foo(1);
}
Gives:
test.d(2,15): Error: @nogc function 'test.foo' cannot call
non- at nogc delegate 'x'
Is it right to refuse the @nogc annotation on foo()? I think here
foo should be allowed to be @nogc, while the main() can't be
@nogc. What do you think?
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list