Decision on container design

bearophile bearophileHUGS at lycos.com
Fri Jan 28 16:01:16 PST 2011


Michel Fortin:

> On the other side 
> of the spectrum, I think that class semantics makes it too easy to have 
> null dereferences,

That's why I have asked for a @ suffix syntax+semantics for notnull reference types in D :-)


> I agree that defining structs to have reference semantics as you have 
> done is complicated. But I like the lazy initialization, and we have a 
> precedent for that with AAs

Built-in AAs are currently broken and in need to be fixed:

import std.stdio: writeln;
void foo(int[int] aa, int n) {
    aa[n] = n;
}
void main() {
    int[int] a;
    foo(a, 0);
    writeln(a);
    a[1] = 1;
    foo(a, 2);
    writeln(a);
}

Bye,
bearophile


More information about the Digitalmars-d mailing list