[Issue 8864] Simpler syntax for array literal of structs from one argument

2018-01-27 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=8864

Andrei Alexandrescu  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||and...@erdani.com
 Resolution|--- |WONTFIX

--- Comment #5 from Andrei Alexandrescu  ---
This is a core language change with many risks associated. A DIP would need to
discuss them all.

Workarounds are possible with library code:

void main() {
BigInt[] data1 = makeArray!BigInt(5, 6, 9);
Ranged!(int,5,10)[] data2 = makeArray!(Ranged!(int,5,10))(5, 6, 9);
Nibble[] data3 = makeArray!Nibble[1, 2, 15]; // Nibble.sizeof == 1
alias Typedef!int Mint;
Mint[] data4 = makeArray!Mint(5, 6, 9);
}

Within the current language this is possible although not super handy:

BigInt[] data1 = only(5, 6, 9).map!(x => BigInt(x)).array;

--


[Issue 8864] Simpler syntax for array literal of structs from one argument

2014-09-21 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=8864

--- Comment #4 from Kenji Hara  ---
*** Issue 7255 has been marked as a duplicate of this issue. ***

--


[Issue 8864] Simpler syntax for array literal of structs from one argument

2014-06-18 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=8864

Kenji Hara  changed:

   What|Removed |Added

   Keywords||pull

--- Comment #3 from Kenji Hara  ---
https://github.com/D-Programming-Language/dmd/pull/3680

--


[Issue 8864] Simpler syntax for array literal of structs from one argument

2014-06-18 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=8864

--- Comment #2 from Kenji Hara  ---
Today following style initializing is properly allwed:

 struct S { this(int n) {} }
 S s = 1;// translated to: T t = T(1);

As a natural conclusion, following syntax should also be accepted IMO.

 S[] a = [1, 2, 3];
 // For each ArrayInitializer elements, implicit struct
 // constructor call of type S should be considered.

Then it could be translated to:

 S[] a = [S(1), S(2), S(3)];

--


[Issue 8864] Simpler syntax for array literal of structs from one argument

2012-10-21 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8864



--- Comment #1 from bearophile_h...@eml.cc 2012-10-21 14:26:37 PDT ---
It's meant to work with 2D arrays too:


struct Nibble {
ubyte u;
this(ubyte ub)
in {
assert(ub < 16);
} body {
this.u = ub;
}
}
void main() {
Nibble[][] data = [[1, 2], [3, 4]];
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---