Fixed-size arrays on the heap

bearophile bearophileHUGS at lycos.com
Thu May 6 04:10:17 PDT 2010


Lars T. Kyllingstad:
> In particular, note Kasumi Hanazuki's post and Andrei's response to it.

Thank you, it seems Andrei agrees with me. But I think here thinks have to be kept tidy, otherwise it's easy to make a mess.

The syntax offers various interesting possibilities for a future International Obfuscated D Code Contest:

import std.stdio: writeln;
struct Arr(int N) {
    int[N] data;
    alias data this;
}
void main() {
    auto p = new Arr!(10);
    *p = 10;
    writeln(p.data); // Output: 10 10 10 10 10 10 10 10 10 10
}


This is not good :-(
Bye,
bearophile


More information about the Digitalmars-d-learn mailing list