[Issue 6521] writeln(const(tuple)) doesn't show the field values

2011-09-09 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=6521


Kenji Hara k.hara...@gmail.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED


--- Comment #3 from Kenji Hara k.hara...@gmail.com 2011-09-09 08:03:36 PDT ---
Fixed.

https://github.com/D-Programming-Language/phobos/commit/4c8cbd2f29637abfadb2d3057a5e747fe8084d4d

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


[Issue 6521] writeln(const(tuple)) doesn't show the field values

2011-08-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=6521



--- Comment #1 from Kenji Hara k.hara...@gmail.com 2011-08-17 18:15:36 PDT ---
Expected prints:

Tuple!(int)(1)
const(Tuple!(int))(1)

There are two ways to fix the problem.

1. Change std.typecons.Tuple!T.toString like follows:

diff --git a/std/typecons.d b/std/typecons.d
index b279abf..b80d6f9 100644
--- a/std/typecons.d
+++ b/std/typecons.d
@@ -491,9 +491,9 @@ assert(s[0] == abc  s[1] == 4.5);
 /**
Converts to string.
  */
-string toString()
+const string toString(this T)()
 {
-enum header = typeof(this).stringof ~ (,
+enum header = T.stringof ~ (,
  footer = ),
  separator = , ;
 Appender!string app;

But this is very hackish to me.

2. Apply my pull request
https://github.com/D-Programming-Language/phobos/pull/126
This patch changes formattedWrite behavior: if a struct type does not have
toString method, formattedWrite formats it like POD (e.g. TypeName(field,
...)).

I think that Tuple is just a POD type, and expected formatting also looks like
the POD.
So, IMHO, std.typecons.Tuple!T.toString is *just a workaround*.
If formattedWrite works correctly, we will no longer need Tuple!T.toString.

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