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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Sep 10 02:36:20 PDT 2011


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



--- Comment #11 from bearophile_hugs at eml.cc 2011-09-10 02:35:35 PDT ---
See also:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=144237

>From that post:

> The solution is to add some symbol that explicitly marks the array as not
> complete, so both the compiler and > the person that later reads the code
> knows some items are missing.
> 
> If no item is missing the compiler probably has to generate an error again:
> 
> int[2] arr = [1, 2, ...]; // compile-time error
> 
> I think that syntax is explicit and readable enough. A problem with this idea is
> this syntax is probably not > used often. On the other hand leaving that trap in
> the D language is not good at all.
> 
> The idea of the dollar symbol can't be used with the ellipsis symbol:
> 
> int[$] arr = [1, 2, ...]; // compile-time error again
> 
> Note: for me this syntax with $ is more commonly useful compared to the "..." syntax.

-- 
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