[Issue 1396] lazy void tuple breaks
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Aug 3 19:52:32 PDT 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1396
------- Comment #3 from default_357-line at yahoo.de 2007-08-03 21:52 -------
(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
--
More information about the Digitalmars-d-bugs
mailing list