No we should not support enum types derived from strings

deadalnix deadalnix at gmail.com
Wed May 12 16:49:12 UTC 2021


On Wednesday, 12 May 2021 at 16:38:10 UTC, Ola Fosheim Grøstad 
wrote:
> I have to admit I never use the terminology monomorphic and 
> polymorphic, so my understanding could be wrong. If so, I am 
> probably not alone in the thread, so for the sake of other 
> readers, maybe someone can provide a definition for monomorphic?

It's quite simple.

*a is polymorphic, because it it an object of type A as far as 
the user of *a is concerned, but it is actually an object of type 
B (or any other subtype of a).

a itself isn't polymorphic, because it is a pointer to an A no 
matter what. It is not a pointer to a B that is observed as if it 
was a pointer to an A. There is nothing more in it to be 
discovered at run time, it's just a pointer.

Even if you do

B *b = ...;
A *a = b;

Then you have not an instance of polymorphism, simply that you 
had a pointer to a B, and now you also have a pointer to an A.


More information about the Digitalmars-d mailing list