Thread overview
[Issue 4660] New: Different writeln output for lazy sequences
August 17, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4660

           Summary: Different writeln output for lazy sequences
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: bearophile_hugs@eml.cc


--- Comment #0 from bearophile_hugs@eml.cc 2010-08-17 05:55:42 PDT ---
This D2 program uses writeln to print a lazy sequence of integers:

import std.stdio: writeln;
import std.algorithm: map;
void main() {
    auto r = map!q{a+1}([1, 2, 3]);
    writeln(r);
}


Output with dmd 2.048:
[2, 3, 4]


But when I print a lazy sequence I'd like some cue in the textual output that the data being printed isn't an array.

In theory the delimiters can just be omitted for lazy sequences, but then if you print a collection of lazy sequences you can't where one sequence ends and the successive ends. So it's better to use delimiters, but different ones.

So this is a possible better output:
(2, 3, 4)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 09, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4660


Andrei Alexandrescu <andrei@metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |andrei@metalanguage.com
         AssignedTo|nobody@puremagic.com        |andrei@metalanguage.com


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 09, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4660



--- Comment #1 from bearophile_hugs@eml.cc 2011-01-09 03:00:22 PST ---
Now I think that a better output is:
[2; 3; 4]

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