[Issue 21808] std.format: It should be possible to change the order of key and value of AAs.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Apr 30 10:14:58 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=21808

--- Comment #5 from Berni44 <bugzilla at bernis-buecher.de> ---
(In reply to Bolpat from comment #4)
> For tuples' %( %) expansion format, reordering works:
> 
>     import std.typecons, std.stdio;
>     writefln("%( %2$s (%1$s) %)", tuple(1, "one"));
>     // prints: one (1)

I'd guess, that this was unintended (there is no unittest containing this, nor
was it mentioned in the PR introducing this) and should be considered a bug (or
an unknown feature?).

Compare:

writefln("%( %2$s (%1$s) %|%)", tuple(1, "one"));

Now it throws. The reason, why the first version works is, because under the
hood it is transformed to something similar to

writefln(" %2$s (%1$s) ", 1, "one");

And now you've got the elements of the tuple as arguments.

Anyway, as I wrote above and in the PR: I like the idea. Let's see, if it will
be accepted.

--


More information about the Digitalmars-d-bugs mailing list