Struct Interface Implementation?
Mehrdad
wfunction at hotmail.com
Sun Jun 12 20:21:47 PDT 2011
Yeah I was referring to something similar to what C# has (aside from the
lack of boxing).
On 6/12/2011 6:46 PM, Andrei Alexandrescu wrote:
> On 6/12/11 8:28 PM, Jonathan M Davis wrote:
>> They aren't virtual. For an interface to work, it has to be virtual.
>> structs
>> are value types, not reference types. They have no virtual table and
>> have no
>> polymorphism.
Why would they need to be virtual? They obviously aren't in C#, but they
still work pretty well (e.g. foreach loops work with List<T>.Enumerator,
which is a struct but which can be treated as the IEnumerator<T>
interface), right?
> He must be referring to nominal conformance. It's been discussed many
> times. There are important disadvantages (e.g. you can't "implement" a
> type alias) but there are advantages too.
> Ultimately we never got around to it.
>
> Andrei
Haha ok, that's a good reason in its own way, thanks. :)
More information about the Digitalmars-d
mailing list