[Issue 1023] Struct implementing interfaces and struct member enumeration

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Mar 5 07:27:44 PST 2007


http://d.puremagic.com/issues/show_bug.cgi?id=1023





------- Comment #3 from larsivar at igesund.net  2007-03-05 09:27 -------
(In reply to comment #2)
> I'm not sure what I think of this idea.  There are a few difficulties - some
> operations would have to check whether an interface reference references a
> struct or class object.  And so casting even to Object would have to have a bit
> of runtime overhead to validate it.
> 
> Moreover, I'm not sure if the necessary conversion of the struct from value
> semantics to reference semantics are likely to cause confusion for some/in some
> circumstances.

There will certainly be technical difficulties, and as such the second request,
enumeration of the methods, would be the half-assed, easy way to do it (all
necessary information in the typeinfo, but for a larger interface you may have
to check for a long list of methods before you know that the correct interface
is implemented).

I would be happy for the functionality to ask whether a struct is of type foo,
using typeid, not necessarily pass it along as type foo. It would probably
cause some inconsistency somewhere in the system though as "struct MyType :
IFoo { }" probably would make people expect that they could pass an instance to
"void bar(IFoo foo);".

> 
> (In reply to comment #0)
> > I started a thread in the NG out of old habit, but I think this is the more
> > correct place.
> 
> Actually, it was once said that feature requests shouldn't be posted on this
> particular Bugzilla, but the policy seems to have faded away lately.  I'm not
> sure.
> 

Yes, there was a discussion about that, at which point most references to Bug
were changed to Issue.


-- 



More information about the Digitalmars-d-bugs mailing list