Regarding fixed size arrays
bearophile
bearophileHUGS at lycos.com
Fri Mar 14 17:11:21 PDT 2014
A small question about the D type system. Currently this code
doesn't compile:
int[5] foo(int[2] a, int[3] b) {
return a ~ b;
}
void main() {}
test.d(2,12): Error: cannot implicitly convert expression
(cast(int[])a ~ cast(int[])b) of type int[] to int[5]
But I think it's easy to modify D/DMD to support code like that.
(A small optimization can even remove any heap allocations from
code like that, because in D fixed-size arrays are passed and
returned by value).
Do you think it's useful/worth supporting code like that?
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list