Bug 3459 – There should be a flavor of file.listdir() that returns a range instead of taking a delegate

Status
RESOLVED
Resolution
INVALID
Severity
enhancement
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2009-10-30T21:21:00Z
Last change time
2015-06-09T01:26:56Z
Assigned to
nobody
Creator
leandro.lucarella

Comments

Comment #0 by leandro.lucarella — 2009-10-30T21:21:07Z
This idiom: ---- foreach (f; listdir(some_dir)) writeln(f); ---- is much more simpler, convenient and clearer than: ---- listdir(some_dir, (string f) { writeln(f) }); ---- Which looks more obscure (specially when the callback is more complex. The first idiom was not possible in D1 without allocating an array for the elements, which can be inefficient, but with ranges in place in D2, I think listdir() should use them. Thanks.
Comment #1 by leandro.lucarella — 2009-10-30T21:35:15Z
OMG! listdir is a opApply candidate, so foreach can be used already with it... Damn! I should go to bed...