On Saturday, 18 May 2013 at 18:41:49 UTC, Walter Bright wrote:
On 5/18/2013 12:30 AM, deadalnix wrote:
On Saturday, 18 May 2013 at 07:14:29 UTC, Walter Bright wrote:
What default would you use for non-null pointers?
Compile time error as a default sound like a nice option.
Probably too late now,
but that is where most language are going now, and having done
quite a lot of
java myself, I can guarantee you that it make sense.
D has that:
@disable this();
which is not the same thing as allowing default constructors.
See:
http://d.puremagic.com/issues/show_bug.cgi?id=10102
struct S
{
int a;
@disable this();
this(int) { a = 1; }
~this() { assert(a !is 0); }
}
enum E : S { A = S.init }
union U
{
S s;
this(this) { assert (s.a !is 0); }
~this() { assert (s.a !is 0); }
}
void foo(out S s, out E e, out U u) { }
void main()
{
S[] arr;
arr.length = 5; // compiles
E[] e;
e.length = 5; // compiles
S[1] x = (S[1]).init; // compiles
U[] u;
u.length = 5; //compiles
foo(arr[0], e[0], u[0]); // compiles
}
@disable this(); commitments are cheap.