On Monday, November 13, 2017 at 10:33:55 AM UTC-5, Stephan Schweitzer wrote:
>
> I have a question about the following code-snippet:
>
>     type I interface {
>      DoSomething()
>     }
>     
>     type F func()
>     
>     func (f F) DoSomething() {
>      f()
>     }
>     
>     func A() {
>      fmt.Println("A")
>     }
>     
>     func B() {
>      fmt.Println("B")
>     }
>     
>     func test() {
>      var _a F = A
>      var _b F = B
>      var a I = _a
>      var b I = _b
>     
>      if a == b { // 2. No compile error but panic
>       // Code
>      }
>     }
>
> It seems to me, that I can break the type system with simple assignments. 
>

Yes, interface is run time generic. It has both good points and bad points.
It is a trade-off. And there are many trade-offs in Go design.
 

> I do not propose that functions should be comparable. My questions are:
>
>    - Why are interfaces comparable by default? 
>    - Why is it not possible to mark an interface as comparable resp. not 
>    comparable?
>    - Why is it not possible do define user defined-equality?
>    - What is the motivation in this language design?
>
> Thanks
> Stephan 
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to