On Wed, 14 Mar 2012 09:27:08 -0400, Martin Nowak <[email protected]> wrote:
In essence, when @type is encountered the compiler looks at
TypeInfo_Struct (in object.di) for the equivalent xfuncname. Then uses
the attributes of that function pointer (and also the parameter
types/count) to compile the given method.
Why would you want to add explicit annotation for implicit
TypeInfo_Struct methods?
Because right now, it's a guessing game of whether you wanted an operation
to be part of the typeinfo's interface. And many times, the compiler
guesses wrong. I've seen countless posts on d.learn saying "why won't
AA's call my opEquals or opHash function?"
With explicit annotation, you have instructed the compiler "I expect this
to be in TypeInfo," so it can take the appropriate actions if it doesn't
match.
I think @type is a very interesting idea if combined with a
string->method lookup in
TypeInfo_Struct, but this wouldn't allow for static type checking.
Yes it would. It has access to TypeInfo_Struct in object.di, so it can
figure out what the signature should be.
-Steve