typedef, Typedef
bearophile
bearophileHUGS at lycos.com
Sat Nov 23 14:32:12 PST 2013
The problem with "T[] a2 = [1, 2, 3];" was reported here:
http://d.puremagic.com/issues/show_bug.cgi?id=8864
And it was discussed a bit here:
http://forum.dlang.org/thread/tyrleoromnxjhvfodmbe@forum.dlang.org
-----------------------
Other problems with Typedef:
http://d.puremagic.com/issues/show_bug.cgi?id=7777
import std.typecons: Typedef;
alias V3 = Typedef!(double[3]);
V3 v1 = [30, 30, -50]; // error
V3 v2 = V3([30, 30, -50]); // OK
void main() {
V3 v3 = [30, 30, -50]; // OK
V3 v4 = V3([30, 30, -50]); // OK
}
-----------------------
http://d.puremagic.com/issues/show_bug.cgi?id=9363
import std.typecons: Typedef;
alias Typedef!(ubyte[]) MyArray;
void main() {
MyArray arr;
arr.length = 10;
arr[] = 0; // error
}
-----------------------
http://d.puremagic.com/issues/show_bug.cgi?id=10778
This works:
alias Matrix = double[260][260];
typedef Matrix Foo;
void main() {
Foo m;
}
This fails:
import std.typecons: Typedef;
alias Matrix = double[260][260];
alias Foo = Typedef!Matrix; // template recursive expansion error
void main() {}
-----------------------
Plus a const-related issue that seems simpler to fix:
http://d.puremagic.com/issues/show_bug.cgi?id=7737
http://d.puremagic.com/issues/show_bug.cgi?id=11584
Bye,
bearophile
More information about the Digitalmars-d
mailing list