Structs implementing interfaces

Tom S h3r3tic at remove.mat.uni.torun.pl
Sat Mar 3 17:35:03 PST 2007


Lars Ivar Igesund wrote:
> 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 :)

If there are no serious technical reasons not to do this,
++votes;  // :)


--
Tomasz Stachowiak



More information about the Digitalmars-d mailing list