--- Comment #4 from 2010-12-11 00:35:09 PST ---
(In reply to comment #3)
> I don't quite get this argument.

Originally array literals used to create fixed length arrays:

auto a = [1,2,3,4];
==> int[4]

Later D was changed so that line creates a dynamic array:

auto a = [1,2,3,4];
==> int[]

that's handy, but now if you have a long array literal and you want a
fixed-sized array you have to count how many items it has. This is not handy,
especially if later you want to add or remove items from the array literal (in
the source code).

It's not handy also because if by mistake you write a bigger number, empty
items are silently created (but only for global fixed-sized literals):

int[5] a = [1,2,3,4];
==> int[5]

So Bill and others have suggested a simple syntax that is easy enough to read,
understand and remember:

int[$] a = [1,2,3,4];
==> int[4]

And to avoid bugs produced by wrong number of items a second syntax may be
introduced, that makes it explicit that there are some auto initialized items:

int[6] a = [1,2,3,4,...];
==> int[6]

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to