[Issue 481] Letting compiler determine length for fixed-length arrays
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Nov 26 12:26:19 PST 2010
http://d.puremagic.com/issues/show_bug.cgi?id=481
bearophile_hugs at eml.cc changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bearophile_hugs at eml.cc
--- Comment #2 from bearophile_hugs at eml.cc 2010-11-26 12:24:55 PST ---
I agree that this syntax is good:
int[$] arr = [1,2,3,4];
But it solves only half of the problem.
Currently this compiles:
int[4] a = [1, 2, 3];
void main() {}
While this generates:
object.Exception: lengths don't match for array copy
void main() {
int[4] a = [1, 2, 3];
}
They are two different situations. But they don't look different, the first
just look like a special case.
To solve the second half of the problem someone has suggested this syntax that
looks good enough:
int[4] a = [1, 2, 3, ...];
a[3] is filled with typeof(a[0]).init.
For more info see bug 3849
--
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