1

Topic: Implicit implementation of the interface

Let's admit is: class Foo {public void Some () {}} interface IMySuperSome {void Some ();} It would be desirable the following: public void Write (IMySuperSome s) {}... Write (new Foo ()); Well it is natural that it was compiled and checked statically. Actually for what reasons decided so not to do?

2

Re: Implicit implementation of the interface

Hello, Gattaka, you wrote: G> Actually for what reasons decided so not to do? How - so? That the compiler tried to lead any class to any interface if only at them methods under the signature coincided?

3

Re: Implicit implementation of the interface

Hello, Gattaka, you wrote: G> Well it is natural that it was compiled and checked statically. Actually for what reasons decided so not to do? interface IManager {void Fire ();} class Gun {public void Fire () {}} var foo = new Gun ();... FireWorker (foo); without contract explicit declaration sooner or later shoots. For esthetes it is possible dynamic emit-it a wrapper (by analogy with ), reducibility of types to check  . But here problems with a wrapper casting to other interfaces (to IDisposable, for example) get out.

4

Re: Implicit implementation of the interface

Hello, Gattaka, you wrote: G> Well it is natural that it was compiled and checked statically. It is called structural typification (in a counterbalance of nominative typification). It is implemented, for example, in Haxe and OCaml.

5

Re: Implicit implementation of the interface

Hello, Gattaka, you wrote: G> Actually for what reasons decided so not to do? Like it would be possible somehow  through dynamic?...

6

Re: Implicit implementation of the interface

Hello, Sharov, you wrote: S> Hello, Gattaka, you wrote: G>> Actually for what reasons decided so not to do? S> like it would be possible somehow  through dynamic?... It is possible, but check in compile time is necessary. Actually QBit86 gave an irrefragable answer.

7

Re: Implicit implementation of the interface

Hello, Gattaka, you wrote: G> It would be desirable the following: In bltoolkit is such  - https://github.com/igor-tkachev/bltoolk … ingTest.cs