Closed bubnenkoff closed 8 years ago
Thank you for your consideration. Do you have a link to the broader context of that quote? As is, I can't see why it's considered sub-optimal.
I decided to ask about it on d forum http://forum.dlang.org/post/fhtjjqeqtdqtbhbvvscy@forum.dlang.org
I don't remember Andrei rationale but I also don't like struct and class separation in D. The reason is that it couples together several orthogonal semantic choices while real applications are much more versatile. Saying that classes are strictly heap types leads to hacks like scoped
. Forcing magical reference semantics leads to ugly Rebindable
workaround when you need to reassign const class reference. The issue with struct destructors not being run if it is allocated on heap is also indirectly caused by such split (because it was functionality not expected and thus not tested).
@Dicebot and what is modern approach to replace structures and classes?
Define "modern" please :) For example, neither Rust nor Go have any notion of classes at all AFAIK.
Yes it conflates a lot of issues...
scope
is something you want tho, being able to say if can or can not keep reference/pointer to a object/memory is nice. Proper scope
not D scope
. The Rebindable
comes from limiting const
syntax and over templitization of the language.
Well at least go have solved polymorphism in a different way, so they don't need traditional classes.
I have found very interesting mention from Alexandrescu that: "Rust has two advantages I can think of: it doesn't have the struct/class split that D does". Could anybody explain why it's bad, and maybe till Volta in WIP it's not later to change it.