January 07, 2021 Re: structure inheritance and polymorphism | ||||
---|---|---|---|---|
| ||||
Posted in reply to ryuukk_ | On Wednesday, 6 January 2021 at 16:54:29 UTC, ryuukk_ wrote: `d` is powerful. But d's `struct` is not . D's `gc` push users to other languages, dragging the legs.d's betterC has no associative array. for users,they want to work like c++,because many of them has c++ background. |
January 07, 2021 Re: structure inheritance and polymorphism | ||||
---|---|---|---|---|
| ||||
Posted in reply to zjh | On Monday, 4 January 2021 at 01:06:20 UTC, zjh wrote: >But I want d to have c++ structure > inheritance and polymorphism. In this way, I think the competition with c++, the odds are better. Structs as polymorphic structures are bad because structs shouldn't be polymorphic, otherwise they have to store a vtable somewhere. If you don't like classes, what about interfaces? The only problem is that they don't support fields which I find myself a bit pitty. You can however simulate it with getters and setters, at least to some kind. With https://dlang.org/phobos/std_experimental_typecons.html you can box a struct to an interface or a class. I don't know how stable it is yet, but I find it pretty interesting. |
January 07, 2021 Re: structure inheritance and polymorphism | ||||
---|---|---|---|---|
| ||||
Posted in reply to sighoya | On Thursday, 7 January 2021 at 11:24:14 UTC, sighoya wrote: I don't like quirky skills. I like to use it out of the box. Just like C++, C++ can be used directly.what you say is right, since the structure should not be polymorphic. Then, D can make something similar to structure / class/interface, because there are many kinds classes. It doesn't need to have a root class like Object. It also has a hierarchical.may be have to use `extern(c++) class`? However, the current structure still does not support inheritance. Even if it does not need polymorphism, inheritance is good, because it can simplify a lot of code. I don't agree with the exclusion of D structure on inheritance. Inheritance is a good tool. |
Copyright © 1999-2021 by the D Language Foundation