[Issue 5945] New: redBlackTree printing

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat May 7 06:17:12 PDT 2011


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

           Summary: redBlackTree printing
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2011-05-07 06:13:17 PDT ---
This little program:


import std.stdio, std.container;
void main() {
    auto t = redBlackTree(0, 7, 5, 2);
    writeln(t);
    writeln(t[]);
}


Prints (DMD 2.053 beta):
std.container.RedBlackTree!(int).RedBlackTree
[0, 2, 5, 7]


But often I'd like collections to print something that's able to generate the
data structure again, as in Python:

>>> s = set([1, 2, 3])
>>> s
set([1, 2, 3])
>>> l = [1, 2, 3]
>>> l
[1, 2, 3]
>>> d = {1:1, 2:2, 3:3}
>>> d
{1: 1, 2: 2, 3: 3}

This is very useful for debugging, logging, for quick scripts, etc.

So I'd like one of the two (the first one?) to print something more like this
instead:

redBlackTree(0, 2, 5, 7)

This too is acceptable:

std.container.redBlackTree(0, 2, 5, 7)

-- 
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