On Tuesday, 6 May 2014 at 00:10:36 UTC, Andrei Alexandrescu wrote:
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));

2. Follow the [ literal ] convention:

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

I'm not a fan of the dual purposing at all. When I see "a.make!T(x, y, z)", I expect that to be identical to "new T(x, y, z)", whether T is an array type or not. The special case will cause more confusion than aid. I'd much prefer separate functions, as others had suggested. "a.zeroArray!int(dim1, dim2)"
  • 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 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