[Issue 12162] writeln(args) and writefln("%s", args) have different semantics with variadic args

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Feb 14 12:58:30 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=12162



--- Comment #7 from Jakob Ovrum <jakobovrum at gmail.com> 2014-02-14 12:58:29 PST ---
(In reply to comment #6)
> (In reply to comment #5)
> > (In reply to comment #4)
> > > 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.
> 
> 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. :)

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: -------


More information about the Digitalmars-d-bugs mailing list