On Saturday, 30 December 2017 at 16:23:05 UTC, Steven
Schveighoffer wrote:
On 12/29/17 7:03 AM, Mike Franklin wrote:
Is that simply because it hasn't been implemented or suggested
yet for D, or was there a deliberate design decision?
It was deliberate, but nothing says it can't actually be done.
All an interface call is, is a thunk to grab the actual object,
and then a call to the appropriate function from a static
vtable. It's pretty doable to make a fake interface. In fact,
I'm pretty sure someone did just this, I have no idea how far
back in the forums to search, but you can probably find it.
Now, it would be nicer if the language itself supported it. And
I don't see any reason why it couldn't be supported. The only
issue I think could be an ABI difference between member calls
of structs and classes, but I think they are the same.
-Steve
Don't forget to implement boxing/unboxing and then write a long
blog post on all the dangers and negative effects of using
interfaces with structs.