Why can't we derive struct's?

Rubn where at is.this
Mon Dec 24 23:54:19 UTC 2018

On Monday, 24 December 2018 at 23:06:26 UTC, 12345swordy wrote:
> On Monday, 24 December 2018 at 19:57:50 UTC, Walter Bright 
> wrote:
>> On 12/24/2018 10:10 AM, H. S. Teoh wrote:
>>> If you can convince him, that would be great!
>> You'd need very compelling use cases.
>> It's like adding more and more horsepower to a car. At some 
>> point, it doesn't make the car better.
>> Or like operator overloading. C++ has much more expansive 
>> rules for operator overloading. They lead to clever programs, 
>> and some people swear by them, but are they *better* programs? 
>> For example,
>> * iostreams
>> * regex DSL 
>> https://pdfs.semanticscholar.org/e630/5f84bca36251fd5a4ffa5f00e0effc8aaa7d.pdf
>> ? I don't buy it. I've never seen an elegant use of the more 
>> expansive power (even though many insist those two examples 
>> are elegant).
> A use case that pops in my head is to avoiding using 
> inheritance as that is not always ideal tool, when it comes to 
> structs/class as you have no control on how it does implicit 
> conversions.

When talking implicit conversion (at least in the same sense as 
C++) you create a new object when doing an implicit conversion. 
How do you envision the implicit conversion would work?

> No Basic Event programming.

Why do you need implicit conversion for this ?

> No Design by Introspection.
> No Data Conversion in Regards to Passing Member Variables.
> You class/struct may end up with functions/variables that you 
> don't want, which creates needless bloat.

You could just use explicit conversion for this, if that's the 
case. Other than not having write 1 extra identifier there 
wouldn't be that much more benefit.

> If you want to support multiple implicit conversion with the 
> current features, then you need multiple alias this, which is 
> not a good solution as
> A.) It is multiple inheritance. Which we both agree it is a 
> terrible idea.
> B.) Multi alias this still hasn't been implemented already. 
> *Throws table*

Idk, all this seems shakey. I avoid implicit conversion as much 
as possible in C++, the times I do use it usually is because of 
some other limitation in C++ that can be solved a different way 
in D. Some concrete examples would help though.

More information about the Digitalmars-d mailing list