Thread overview
[Issue 21808] Position format specifiers don't work for AAs
Apr 07, 2021
Bolpat
Apr 12, 2021
Berni44
[Issue 21808] std.format: It should be possible to change the order of key and value of AAs.
Apr 29, 2021
Berni44
Apr 29, 2021
Dlang Bot
Apr 29, 2021
Bolpat
Apr 30, 2021
Berni44
May 05, 2021
Dlang Bot
April 07, 2021
https://issues.dlang.org/show_bug.cgi?id=21808

Bolpat <qs.il.paperinik@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |qs.il.paperinik@gmail.com

--
April 12, 2021
https://issues.dlang.org/show_bug.cgi?id=21808

Berni44 <bugzilla@bernis-buecher.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@bernis-buecher.de
           Severity|enhancement                 |normal

--- Comment #1 from Berni44 <bugzilla@bernis-buecher.de> ---
This is related to https://issues.dlang.org/show_bug.cgi?id=18599 but not identical.

--
April 29, 2021
https://issues.dlang.org/show_bug.cgi?id=21808

Berni44 <bugzilla@bernis-buecher.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Position format specifiers  |std.format: It should be
                   |don't work for AAs          |possible to change the
                   |                            |order of key and value of
                   |                            |AAs.
           Severity|normal                      |enhancement

--- Comment #2 from Berni44 <bugzilla@bernis-buecher.de> ---
Changing this to "enhancement", because normal use of positional parameters has a completely different meaning - it gives the position of an argument in the function call and has nothing to do with the order of the elements of a single argument.

Anyway, I see the need for the possibility to change the order; and positional arguments don't make any sense inside of a compound specifier. Therefore I think, it is OK to (ab)use them like suggested here. But then it's not a bug, but an enhancement.

--
April 29, 2021
https://issues.dlang.org/show_bug.cgi?id=21808

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #3 from Dlang Bot <dlang-bot@dlang.rocks> ---
@berni44 created dlang/phobos pull request #8020 "Fix Issue 21808 - std.format: It should be possible to change the order of key and value of AAs." fixing this issue:

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

https://github.com/dlang/phobos/pull/8020

--
April 29, 2021
https://issues.dlang.org/show_bug.cgi?id=21808

--- Comment #4 from Bolpat <qs.il.paperinik@gmail.com> ---
(In reply to Berni44 from comment #2)
> Changing this to "enhancement", because normal use of positional parameters has a completely different meaning - it gives the position of an argument in the function call and has nothing to do with the order of the elements of a single argument.
> 
> Anyway, I see the need for the possibility to change the order; and positional arguments don't make any sense inside of a compound specifier. Therefore I think, it is OK to (ab)use them like suggested here. But then it's not a bug, but an enhancement.

For tuples' %( %) expansion format, reordering works:

    import std.typecons, std.stdio;
    writefln("%( %2$s (%1$s) %)", tuple(1, "one"));
    // prints: one (1)

--
April 30, 2021
https://issues.dlang.org/show_bug.cgi?id=21808

--- Comment #5 from Berni44 <bugzilla@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.

--
May 05, 2021
https://issues.dlang.org/show_bug.cgi?id=21808

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #6 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/phobos pull request #8020 "Fix Issue 21808 - std.format: It should be possible to change the order of key and value of AAs." was merged into master:

- fbc4c53d7bd1916d5253c6d4a7bd2d61b80d31c3 by berni44:
  Fix Issue 21808 - std.format: It should be possible to change the order of
key and value of AAs.

https://github.com/dlang/phobos/pull/8020

--