Re: [go-nuts] Interface-keyed maps and non-comparable dynamic key values

2017-05-04 Thread Paul Jolly
Just realised I accidentally replied to Ian off-list: > My question is why something that could be caught at compile time is not > > caught at compile time: > > I suspect mostly because nobody thought of it. > > That said, note that this in effect a language change. It is possible > to construct

Re: [go-nuts] Interface-keyed maps and non-comparable dynamic key values

2017-04-04 Thread Paul Jolly
> > IMO implementing such a compile check would be contrary to the "least > WTF" principle. Imagine something like > > type S struct { > f func() > } > > func (s S) Impl() {} > > func Foo() I { > return S{} > } > > m[Foo()] = true > > The compiler is able to check at compile

Re: [go-nuts] Interface-keyed maps and non-comparable dynamic key values

2017-04-04 Thread Konstantin Khomoutov
On Tue, 4 Apr 2017 07:27:17 -0700 Ian Lance Taylor wrote: > >> When you insert a value keyed by S{}, the compiler creates a value > >> of type I which has S as its dynamic type and S{} as its value. > >> > >> The program as speficied panics with > > > > > > Apologies if it

Re: [go-nuts] Interface-keyed maps and non-comparable dynamic key values

2017-04-04 Thread Ian Lance Taylor
On Tue, Apr 4, 2017 at 3:41 AM, Paul Jolly wrote: >> When you insert a value keyed by S{}, the compiler creates a value of >> type I which has S as its dynamic type and S{} as its value. >> >> The program as speficied panics with > > > Apologies if it wasn't clear from my

Re: [go-nuts] Interface-keyed maps and non-comparable dynamic key values

2017-04-04 Thread Paul Jolly
> > When you insert a value keyed by S{}, the compiler creates a value of > type I which has S as its dynamic type and S{} as its value. > > The program as speficied panics with > Apologies if it wasn't clear from my original email, but I understand why this panics; I further acknowledge the

Re: [go-nuts] Interface-keyed maps and non-comparable dynamic key values

2017-04-04 Thread Konstantin Khomoutov
On Tue, 4 Apr 2017 02:40:31 -0700 (PDT) Paul Jolly wrote: > *I couldn't find anything previously on the question below, but as > ever would appreciate any pointers to prior questions/issues etc.* > > Consider the following (playground >

[go-nuts] Interface-keyed maps and non-comparable dynamic key values

2017-04-04 Thread Paul Jolly
*I couldn't find anything previously on the question below, but as ever would appreciate any pointers to prior questions/issues etc.* Consider the following (playground ): package main import ( "fmt" ) type S struct { f func() } func