Bug 300 – Lazy Delegate Evaluation

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-08-21T00:50:00Z
Last change time
2014-02-15T13:19:25Z
Keywords
rejects-valid
Assigned to
bugzilla
Creator
ddparnell

Comments

Comment #0 by ddparnell — 2006-08-21T00:50:52Z
The example in the documentation fails to compile. We get the message... "voids have no value" // TEST 1 import std.stdio; void dotimes(int count, void delegate() exp) { for (int i = 0; i < count; i++) exp(); } void foo1() { int x = 0; dotimes(10, writef(x++)); } bool scase(bool b, void delegate() dg) { if (b) { dg(); return true; } return false; } void cond(bool delegate()[] cases ...) { foreach (c; cases) { if (c()) break; } } void foo2() { int v = 2; cond ( scase(v == 1, writefln("it is 1")), scase(v == 2, writefln("it is 2")), scase(v == 3, writefln("it is 3")), scase(true, writefln("it is the default")) ); } void main() { foo1(); foo2(); } // ------- code ends ---- I had to change "writef(...)" to "{writef();}" to get it to compile.
Comment #1 by bugzilla — 2006-09-02T19:45:22Z
Fixed 0.166