Why can't we derive struct's?

12345swordy alexanderheistermann at gmail.com
Tue Dec 25 04:48:22 UTC 2018


On Monday, 24 December 2018 at 23:54:19 UTC, Rubn wrote:

>
> 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?

Similar to how C# does it.
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/implicit

> Why do you need implicit conversion for this ?

I meant that you can't program an event that runs every time an 
implicit conversion occurs.(Unless you hacked the compiler that 
does that for you...)

> You could just use explicit conversion for this

I am specifically talking about implicit conversions via 
inheritance and why it not an idea tool, as (Which I had said 
before) you have no control on how it does implicit conversions. 
I am not talking about explicit conversions here.

>> 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.

... What limitations in C++ are you talking about?

Alex


More information about the Digitalmars-d mailing list