www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10904] New: "%(%s %)" format string support for std.container.Array too

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10904

           Summary: "%(%s %)" format string support for
                    std.container.Array too
           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



import std.stdio: writefln;
import std.container: Array;
void main() {
    int[10] a1;
    writefln("%(%d %)", a1);
    Array!int a2;
    a2.length = 10;
    writefln("%(%d %)", a2);
}


With dmd 2.064alpha it gives a run-time error:

std.format.FormatException ...\dmd2\src\phobos\std\format.d(2472): Expected
'%s' format specifier for type 'Array!int'

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 26 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10904


hsteoh quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hsteoh quickfur.ath.cx



Hmm. Looking at the code, it seems that %(...%) _should_ be able to support any
input range, so if you write writefln("%(...%)", a1[]);, it should work, I
think.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 26 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10904




OK, confirmed that using opSlice (i.e., a2[]) works.

It's not as nice, though. We *could* implement a suitable version of toString
that will get picked up by std.format without needing to write [].

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 26 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10904


Dmitry Olshansky <dmitry.olsh gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dmitry.olsh gmail.com



05:19:47 PDT ---

 OK, confirmed that using opSlice (i.e., a2[]) works.
 
 It's not as nice, though. We *could* implement a suitable version of toString
 that will get picked up by std.format without needing to write [].
Well, that would going way too long in the wrong direction. %(..%) prints ranges, period. Leave containers alone :) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 27 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10904


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID





 Well, that would going way too long in the wrong direction. %(..%) prints
 ranges, period. Leave containers alone :)
OK, I close down this ER. Thank you for all the answers. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 27 2013