Structs implementing interfaces

Lars Ivar Igesund larsivar at igesund.net
Sat Mar 3 13:45:52 PST 2007


Structs in D are very simple which is good, but in some cases they are just
too simple. In many cases you would want to handle struct instances as if
they were Object derivates, by calling methods on them, methods that
implement an interface. The most obvious example is toUtf8 (or toString).
As it is now, for instance in a formatter, if it detects that the input is
a struct, you have no way of figuring out whether the struct implements an
interface or not.

This is thus a request to make it possible to say that a struct implements
an interface and thus can be typeid'ed on other types (interfaces) than
those of the structs themselves. An enumeration of the methods of the
struct would also be nice.

Thanks :)

-- 
Lars Ivar Igesund
blog at http://larsivi.net
DSource, #d.tango & #D: larsivi
Dancing the Tango



More information about the Digitalmars-d mailing list