On Wednesday, 12 March 2014 at 13:55:35 UTC, Steven Schveighoffer wrote:
On Wed, 12 Mar 2014 09:51:32 -0400, monarch_dodra <[email protected]> wrote:

On Wednesday, 12 March 2014 at 13:34:33 UTC, Steve Teale wrote:

void main()
{
  I[] arr = [new A, new B];
  foreach(i; arr) { (cast(typeof(i.myType()) i).foo() }
}

myType() is a virtual function, so calling it through the interface type should get the correct version right?, and then the cast should cause a call to A or B.

It will *call* the correct version, but the signature used will still statically be the interface's signature.

There is no foo in the interface definition.

I meant call relative to "myType()". I can see how that was not clear actually. Sorry.

The code is invalid, as is the idea you can declare variables based on a runtime type definition.

Yup.

Reply via email to