On Saturday, 27 May 2017 at 14:12:09 UTC, Ola Fosheim Grøstad
wrote:
I wonder, what would break if all the features of class was
merged into struct?
Imagine that:
class Something ... { ... }
is lowered into:
struct _class_Something ... { ... }
alias Something = MagicClassRef!_class_Something;
Is it conceivable with some language changes, a bit of
automated source updating and a little bit of breakage?
It's not "a little bit", it's ABI down the drain, along with a
good part of runtime. And we'd lose interfaces and extern(C++).
That being said, it is totally possible today to have struct
wrappers over classes, both malloc'ed and stack-allocated. The
problem is that destruction is always @system (due to reasons
described in my "Destructor attribute inheritance" thread:
http://forum.dlang.org/thread/wtxkfylodzaaifoja...@forum.dlang.org). And one has to adopt a discipline not to escape references.
Once DIP1000 is fully realized, at least the latter part will
become unnecessary.