Restriction on interface function types
Steven Schveighoffer
schveiguy at yahoo.com
Wed Mar 12 06:55:36 PDT 2014
On Wed, 12 Mar 2014 09:51:32 -0400, monarch_dodra <monarchdodra at gmail.com>
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. The code is invalid, as is
the idea you can declare variables based on a runtime type definition.
-Steve
More information about the Digitalmars-d
mailing list