import std.stdio; template tuple(T...) { alias T tuple; } void test(lazy tuple!(void, void) a) { a[0](); a[1](); } void main() { test(writefln("Hello"), writefln("World")); } Expected: "Hello\nWorld" Resulted: Error: cannot have parameter of type void. Observed: Seems as if the lazy isn't being applied to all the tuple members as it should be. --downs
Added comment: Seems to happen whenever the tuple contains at least one void, for every void in the tuple.
(In reply to comment #0) > import std.stdio; > template tuple(T...) { alias T tuple; } > void test(lazy tuple!(void, void) a) { a[0](); a[1](); } > void main() { test(writefln("Hello"), writefln("World")); } > > Expected: "Hello\nWorld" > Resulted: Error: cannot have parameter of type void. > Observed: Seems as if the lazy isn't being applied to all the tuple members as > it should be. > > --downs > Since 'lazy void' is really shorthand for 'void delegate()' I wouldn't actually have expected 'lazy' to work in this way anyhow... Although it could indeed be useful. Try running it with 'tuple!(lazy void, lazy void) a' and it should work. I consider this an enhancement request, or clarification request, rather than a bug. (It'd be a nice enhancement, though.)
(In reply to comment #2) > Since 'lazy void' is really shorthand for 'void delegate()' I wouldn't actually > have expected 'lazy' to work in this way anyhow... Works with int. gentoo-pc ~/d $ cat bug.d && echo ---- && gdc bug.d -o bug && ./bug import std.stdio; template tuple(T...) { alias T tuple; } void test(lazy tuple!(int, int) a) { writefln("Eval now"); writefln(a[0], "-", a[1]); } void main() { test({writefln("Hello"); return 1; }(), {writefln("World"); return 2; }()); } ---- Eval now World Hello 1-2 > Although it could indeed be > useful. Try running it with 'tuple!(lazy void, lazy void) a' and it should > work. > > I consider this an enhancement request, or clarification request, rather than a > bug. (It'd be a nice enhancement, though.) > import std.stdio; template tuple(T...) { alias T tuple; } void test(tuple!(lazy void, lazy void) a) { a[0](); a[1](); } void main() { test(writefln("Hello"), writefln("World")); } gentoo-pc ~/d $ gdc bug.d -o bug bug.d:3: expression expected, not 'lazy' Thanks for the suggestion, though. --downs
Fixed DMD1.054.