06-May-2014 04:10, Andrei Alexandrescu пишет:
So I'm looking at creation functions and in particular creation
functions for arrays.

1. Follow the new int[n] convention:

auto a = allok.make!(int[])(42);
assert(a.length == 42);
assert(a.equal(repeat(0, 42));

Have this primitive to keep it simple.
(i.e. make => pass args to "ctor")
Especially in the case of int[][][] and such.


2. Follow the [ literal ] convention:

auto a = allok.make!(int[])(42);
assert(a.length == 1);
assert(a[0] == 42);


This option is std.array.array in a disguise or rather the builder pattern. Would be nice to have it separately from allocator.

My argument is:
a) It should work for any container.
b) Is related not to an allocator but rather to the type of container (and its associated allocator). Arrays are unfortunately oblivious of allocators.

--
Dmitry Olshansky
    • Re: API Andrei Alexandrescu via Digitalmars-d
      • Re: API Walter Bright via Digitalmars-d
        • Re: API Andrei Alexandrescu via Digitalmars-d
  • Re: API Idan Arye via Digitalmars-d
  • Re: API Brad Anderson via Digitalmars-d
    • Re: API bearophile via Digitalmars-d
  • Re: API ed via Digitalmars-d
  • Re: API Steven Schveighoffer via Digitalmars-d
  • Re: API Yota via Digitalmars-d
  • Re: API Andrei Alexandrescu via Digitalmars-d
  • Re: API Dmitry Olshansky via Digitalmars-d
    • Re: API Steven Schveighoffer via Digitalmars-d
  • Re: API Byron via Digitalmars-d

Reply via email to