API
Dmitry Olshansky via Digitalmars-d
digitalmars-d at puremagic.com
Tue May 6 12:32:23 PDT 2014
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
More information about the Digitalmars-d
mailing list