No we should not support enum types derived from strings
deadalnix
deadalnix at gmail.com
Wed May 12 01:53:09 UTC 2021
On Wednesday, 12 May 2021 at 00:22:56 UTC, Walter Bright wrote:
> On 5/11/2021 12:56 PM, deadalnix wrote:
>> The fact is that you can't get rid of 1. and support OOP,
>> because polymorphism is a key ingredient of OOP.
>
> Converting a derived class reference to a base class reference
> is an "implicitly convert" operation, not a special-kind-of
> conversion.
That is trivially demonstrably false. Consider:
class A {}
class B : A {}
B function() implicitly converts to A function()
But
byte function() doesn't implicitly converts to int function()
Clear, the implicit conversion from byte to int is of different
nature than the one from B to A, and one doesn't have to dig very
deep to find these differences.
Now, mind you, this is not a problem. At all. After all, B is a
subtype of A, while byte is not a subtype of int. There are
different kind of implicit conversions. This is pefectly sound
and required if D wants to have implicit conversion of things
which aren't subtypes of each others. There are no ways around it.
Let's just not pretend it's the same, because this from these
erroneous assumptions that bad design grows.
More information about the Digitalmars-d
mailing list