Comment #0 by bearophile_hugs — 2013-05-07T15:02:36Z
I don't know if this a Phobos or DMD bug.
import std.stdio: writeln;
void main () {
auto aa = [1: 2];
aa.writeln;
writeln(aa);
}
Output with dmd 2.063beta:
AssociativeArray!(int, int)(18C2FE0)
[1:2]
Expected something like:
[1: 2]
[1: 2]
Comment #2 by bearophile_hugs — 2013-05-07T18:05:43Z
(In reply to comment #1)
> (In reply to comment #0)
> > I don't know if this a Phobos or DMD bug.
>
> This is a regression in 2.063a.
>
> https://github.com/D-Programming-Language/dmd/pull/1975
Thank you Kenji.
- - - - - - -
A mostly unrelated question. Python dict formatting uses a space after the colon, probably to increase readability:
>>> {1:2, 2:3}
{1: 2, 2: 3}
I kind of like that extra space. Is it a good idea to add it to D AA formatting?
Comment #3 by k.hara.pg — 2013-05-07T18:22:04Z
(In reply to comment #2)
> A mostly unrelated question. Python dict formatting uses a space after the
> colon, probably to increase readability:
>
> >>> {1:2, 2:3}
> {1: 2, 2: 3}
>
> I kind of like that extra space. Is it a good idea to add it to D AA
> formatting?
I have no argument about the space after colon...
void main() {
import std.stdio;
// Fixed a while ago
pragma(msg, [1, 2]); // [1, 2]
writeln([1, 2]); // [1, 2]
// Currently different output between compiler and std-lib
pragma(msg, [1:1, 2:2]); // [1:1,2:2]
writeln([1:1, 2:2]); // [1:1, 2:2]
}
Both compiler and Phobos prints no space after colon. Currently it is consistent.
But, I can argue that compiler should insert a space after comma in AA literal printing.
Comment #4 by github-bugzilla — 2013-05-08T03:51:49Z