http://d.puremagic.com/issues/show_bug.cgi?id=3813
--- Comment #3 from [email protected] 2010-08-09 07:31:25 PDT --- In dmd 2.048beta the situation is improved, but it's not good enough yet. This D2 program: import std.stdio, std.typetuple, std.typecons; void main() { auto a1 = ["10", "20"]; writeln(a1); auto a2 = [10, 20]; writeln(a2); char[] a3 = ['5', '7', '9']; writeln(a3); auto t1 = TypeTuple!(10, "20", '7'); writeln(t1); auto t2 = tuple(10, "20"); writeln(t2); } Prints: [10, 20] [10, 20] 579 10207 Tuple!(int,string)(10, 20) >From that output there is now way, in both the array and the TypeTuple, to tell apart strings, numbers and chars. This doesn't help D2 debugging, and it doesn't help all when you write quick scripts that often use a simple writeln() for their output. In both cases being able to tell apart numbers and strings in the output is quite important. So my warm suggestion is to put "" around strings, '' around chars when they are printed inside collections (Inside string literals special chars need to be escaped). So my expected output is: ["10", "20"] [10, 20] 579 10"20"'7' Tuple!(int,string)(10, "20") A possible alternative output: ["10", "20"] [10, 20] ['5', '7', '9'] 10"20"'7' Tuple!(int, string)(10, "20") A similar Python 2.7 program: from collections import namedtuple a1 = ["10", "20"] print a1 a2 = [10, 20] print a2 a3 = ['5', '7', '9'] print a3 t1 = (10, "20", '7') print t1 t2 = namedtuple('Two', 'a b')(10, "20") print t2 Prints: ['10', '20'] [10, 20] ['5', '7', '9'] (10, '20', '7') Two(a=10, b='20') (In Python strings can be delimited by '' too.) In D I presume writeln() can't tell that the input is a TypeTuple, so it can't print something like the () as in Python. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
