Well, except that then it's less obvious that an object is
ref-counted and less likely that the programmer using it will
realize that the object expects to have a deterministic
lifetime. So, it might actually make the situation worse and
make it so that programmers are more likely to get wrong. I
don't think that it's clear at all that the situation will be
better with regards to programmers getting it right if it's in
the language. Maybe it will be, but maybe it won't.
- Jonathan M Davis
Well then, there is another solution: enable inheritance for
structs as well. Then we have polymorphie and deterministic
lifetimes. Of course we cannot expect too much magic. But an
example:
----
struct A {
int hello() {
return 42;
}
}
struct B : A {
override int hello() {
return 23;
}
}
void foo(A* a) {
writeln(a.hello()); // prints 23
}
void main() {
A* b = new B();
foo(b);
}
----
That shouldn't be too complex, since it follows the rules of C++:
http://cpp.sh/9r6k