On 8/21/11 4:02 PM, Nick Sabalausky wrote:
"bearophile"<bearophileh...@lycos.com> wrote in message
news:j2rh7g$2tfq$1...@digitalmars.com...
To this innocent-looking D code, do you see the problem?
void foo(Pair[] sol) {
if (isSolution(sol[$-1]))
if (!best.length || sol.length< best.length)
best = sol.dup;
else
foreach (next; alternatives(sol[$-1]))
if (!canFind(sol, next))
foo(sol ~ [next]);
}
That's why I always use braces to avoid the construct "if(cond) stmt;
if(cond) stmt; else..."
There is a situation where I'd like D to require braces:
http://d.puremagic.com/issues/show_bug.cgi?id=4375
That's a fantastic idea.
Yah, it's pretty neat, and very much in the spirit of D. I'd missed it.
Andrei