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.
  • API Andrei Alexandrescu via Digitalmars-d
    • Re: API Adam D. Ruppe via Digitalmars-d
      • Re: API Adam D. Ruppe via Digitalmars-d
        • Re: API bearophile via Digitalmars-d
          • Re: API Adam D. Ruppe via Digitalmars-d
            • Re: API bearophile via Digitalmars-d
              • Re: API Adam D. Ruppe via Digitalmars-d
      • Re: API Orvid King via Digitalmars-d
    • Re: API bearophile via Digitalmars-d
      • Re: API H. S. Teoh via Digitalmars-d
    • Re: API Brian Schott via Digitalmars-d
    • Re: API Walter Bright via Digitalmars-d
      • Re: API MattCoder via Digitalmars-d
      • Re: API Andrei Alexandrescu via Digitalmars-d
        • Re: API Walter Bright via Digitalmars-d
          • Re: API Andrei Alexandrescu via Digitalmars-d
          • Re: API monarch_dodra via Digitalmars-d
    • Re: API Idan Arye via Digitalmars-d

Reply via email to