Restriction on interface function types

Steve Teale steve.teale at britseyeview.com
Wed Mar 12 06:13:08 PDT 2014


On Wednesday, 12 March 2014 at 11:56:43 UTC, Steven Schveighoffer 
wrote:
> On Wed, 12 Mar 2014 06:57:08 -0400, Steve Teale 
> <steve.teale at britseyeview.com> wrote:
>
>
> What you want simply isn't possible. An interface binds at 
> runtime, and you need to declare types at compile-time. You 
> can't use an interface method to define the type of y.
>
> -Steve

Steve

OK, it was a bad illustrative example, but

(cast(typeof(a.myType()) whatever).foo();

could be useful, when foo() is not in the interface.

It was the failure of auto in an interface that I was remarking 
on - should at least be documented. Also the covariant return 
values as suggested by md don't work either.

Steve


More information about the Digitalmars-d mailing list