On 5/5/14, Adam D. Ruppe via Digitalmars-d <[email protected]> wrote: > On Tuesday, 6 May 2014 at 00:10:36 UTC, Andrei Alexandrescu wrote: >> 1. Follow the new int[n] convention: >> 2. Follow the [ literal ] convention: > > We could combine these pretty easily: > > struct Length { size_t length; } > > allok.make!(int[])(Length(42)); // #1 > allok.make!(int[])(1,2,3); // #2 btw could also use IFTI here > which is nice > > This also potentially gives a third option: > > allok.make!(Length(42), 5); // length == 42, all elements == 5, > typeof(return) == typeof(args[1])[] > > > I kinda like that, though I'm not sure if I'd still like it if I > used it regularly. Then, of course, we can also take other ranges > to initialize too. >
I actually think this is a very elegant solution, but does open the question, should `allok.make!(42)` create an array initialized to 42, or an array with length of 42? Provided this is documented, I don't think the ambiguity should be an issue.
