[Issue 3849] [missing error] Array literal length doesn't match

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Sep 11 04:11:31 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=3849



--- Comment #13 from bearophile_hugs at eml.cc 2011-09-11 04:11:11 PDT ---
(In reply to comment #12)

> >> If no item is missing the compiler probably has to generate an 
> >> error again:
> >> 
> >> int[2] arr = [1, 2, ...]; // compile-time error
> 
> I'm not sure about this.  I can imagine someone wanting it to work when the
> length is a template parameter, in order to initialise only the first n members
> where n is fixed.

I see.


> And should we allow a value to precede the ..., like
> 
>     int[100] arr = [1, 2, 42...];
> 
> (all elements beyond the first two initialised to 42)?

D allows floating point literals without decimal digits:

float[6] arr = [1., 2., 42....];

This is too much ugly, so I think it's much better to require a comma before
the ellipsis.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list