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. 

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