digitalmars.D.bugs - [Issue 12162] New: writeln(args) and writefln("%s", args) have different semantics with variadic args
- d-bugmail puremagic.com (30/32) Feb 14 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12162
- d-bugmail puremagic.com (14/32) Feb 14 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12162
- d-bugmail puremagic.com (9/10) Feb 14 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12162
- d-bugmail puremagic.com (8/14) Feb 14 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12162
- d-bugmail puremagic.com (12/12) Feb 14 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12162
- d-bugmail puremagic.com (8/11) Feb 14 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12162
- d-bugmail puremagic.com (11/18) Feb 14 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12162
- d-bugmail puremagic.com (9/27) Feb 14 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12162
https://d.puremagic.com/issues/show_bug.cgi?id=12162 Summary: writeln(args) and writefln("%s", args) have different semantics with variadic args Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: nobody puremagic.com ReportedBy: andrej.mitrovich gmail.com 12:38:46 PST --- ----- import std.stdio; void test(T...)(T args) { writefln("%s", args); writeln(args); } void main() { test(1, 2, 3, 4); } ----- $ dmd test.d1 1234-- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 14 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12162 Jakob Ovrum <jakobovrum gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakobovrum gmail.com -------- import std.stdio; void test(T...)(T args) { writefln("%s", args); writeln(args); } void main() { test(1, 2, 3, 4); } ----- $ dmd test.dWell, what did you expect? I personally would've expected it to error on the basis of having received too many arguments (or was that error phased out?), but this behaviour looks correct to me. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------1 1234
Feb 14 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12162 12:47:18 PST ---Well, what did you expect?I guess I'm looking for some kind of eager version of %s? This isn't necessarily a bug, but could be an enhancement request (unless it can already be done with another format spec?). -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 14 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12162 ---It would necessitate treating all trailing arguments equally (which would arguably only make sense for %s). -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------Well, what did you expect?I guess I'm looking for some kind of eager version of %s? This isn't necessarily a bug, but could be an enhancement request (unless it can already be done with another format spec?).
Feb 14 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12162 Andrej Mitrovic <andrej.mitrovich gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID 12:52:14 PST --- Ah I know of a cute trick though: writefln("%s", args.only); -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 14 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12162 12:53:09 PST ---Ah I know of a cute trick though: writefln("%s", args.only);And come to think of it, I think bearophile has a couple of format() enhancement requests specifically for tuples. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 14 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12162 12:55:28 PST ---Specifically, the following works for arrays but not for tuples: writefln("%(%s %)", [1, 2]); // prints "1 2" Perhaps if we could modify the syntax a little bit.. writefln("%!(%s %)", TypeTuple!(1, 2)); // would print "1 2" Disregard the TypeTuple misnomer though. :) -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------Ah I know of a cute trick though: writefln("%s", args.only);And come to think of it, I think bearophile has a couple of format() enhancement requests specifically for tuples.
Feb 14 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12162 ---It is no surprise that tuples (aka template argument list) work differently from arrays, considering their auto-expansive behaviour. bearophile's ER pertains std.typecons.Tuple, not in-built "type tuples". -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------Specifically, the following works for arrays but not for tuples: writefln("%(%s %)", [1, 2]); // prints "1 2" Perhaps if we could modify the syntax a little bit.. writefln("%!(%s %)", TypeTuple!(1, 2)); // would print "1 2" Disregard the TypeTuple misnomer though. :)Ah I know of a cute trick though: writefln("%s", args.only);And come to think of it, I think bearophile has a couple of format() enhancement requests specifically for tuples.
Feb 14 2014