Optional braces
bearophile
bearophileHUGS at lycos.com
Sun Aug 21 11:02:24 PDT 2011
Nick Sabalausky:
> Yuck! I'd really hate that.
Recently I have converted this Python code:
def foo(sol):
global best
if is_solution(sol[-1]):
if best or len(sol) < len(best):
best = list(sol)
else:
for next in alternatives(sol[-1]):
if next not in sol:
foo(sol + [next])
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]);
}
There is a situation where I'd like D to require braces:
http://d.puremagic.com/issues/show_bug.cgi?id=4375
Bye,
bearophile
More information about the Digitalmars-d
mailing list