[Issue 8680] SpanMode.breadth is incorrectly named and implementation fails in Linux

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Sep 18 07:03:00 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8680


entheh at cantab.net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |entheh at cantab.net


--- Comment #2 from entheh at cantab.net 2012-09-18 07:03:41 PDT ---
I originally identified the bug. First I'd like to comment more on the
terminology, and give my proposed fix.

The description in the documentation matches the implementation, and reflects
what a user would find most useful. There is no implementation bug that I'm
aware of (see below for more discussion of this).

The only issue is naming. The SpanMode enum constants 'depth' and 'breadth'
actually describe 'postorder depth-first' and 'preorder depth-first'
respectively. That means the word 'depth' carries insufficient information to
identify it, and 'breadth' is just wrong. If you're unfamiliar with tree
traversal algorithms and can't immediately see this, then please review the
examples and terminology on http://en.wikipedia.org/wiki/Tree_traversal .
(Pretty much everyone missed the point on the newsgroup - please do this if
you're at all uncertain!)

So here's my proposed fix:

enum SpanMode {
  shallow,
  preorder,
  postorder;

  @deprecated alias preorder breadth;
  @deprecated alias postorder depth;
}

As for the behaviour on Linux - I don't think this is actually violating the
spec. Probably what you're complaining about is that the directories 'c' and
'b' are coming before the files '2.txt' and '1.txt' which are siblings.
However, the spec doesn't say anything about a directory's position relative to
its siblings. It only talks about a directory's position relative to its
children. See the difference:

For preorder depth-first:
  a/b
must come before
  a/b/1.txt

But
  a/b
has no ordering constraint with
  a/1.txt

If 'directories first' or 'directories last' is required, then that would be
more of a feature request than a bug :) It could probably be generalised to
child sorting - the user could supply a comparator which (if present) is used
to sort the children in each directory.

Hope that helps :)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list