Re: Dynamic array initialization syntax

2011-02-16 Thread Andrej Mitrovic
Oh, but there's a call to array. I guess that could slow things down, sorry.

Re: Dynamic array initialization syntax

2011-02-16 Thread Andrej Mitrovic
import std.stdio; import std.range; auto newArray(T)(T value, size_t size) { return array(take(repeat(value), size)); } void main() { auto a1 = newArray(5, 3); assert(a1 == [5, 5, 5]); } __Dmain:; Function begin, communal sub esp, 28 ; 000

Dynamic array initialization syntax

2011-02-16 Thread bearophile
I have suggested a simple initialization syntax for dynamic arrays, similar to the syntax used for fixed-sized arrays: http://d.puremagic.com/issues/show_bug.cgi?id=5603 void main() { auto a2 = new int[5] = void; auto a1 = new int[5] = 1; auto m2 = new int[][](5, 5) = void; auto m