On Sun, 24 Aug 2014 13:22:49 +0000 Stefan Frijters via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote:
@nogc is a part of signature. gc-function can't call @nogc-one. the same is with calling @system function from @safe one, for example. or impure function from pure. so to say, foreach() creates implicit delegate withoit '@nogc' attribute, that's why compiler complains. there is currenly no way to specify attributes for such implicit delegates. this will work, but you'll not be able to call writeln(): nogc: void main() { import std.stdio; foreach (element; NumberRange(3, 7)) { // line 21 //write(element, ' '); // this will fail with // @nogc function 'z00.main.__foreachbody1' cannot call // non-@nogc function 'std.stdio.write!(int, char).write' } } what we need here is something like: foreach (element; NumberRange(3, 7) @nogc) { ... } but alas...
signature.asc
Description: PGP signature