Re: [go-nuts] "Craftsman's" Go Generics proposal

2018-09-11 Thread robert engels
I’m sorry, but I don’t think your reasoning is correct. See the code below. Less lines, and better functionality & design, and you can do this today… (trivial to also add the ComplexPrice) Although I think you should be able to write: ip := Prices{1,2,3} and the compiler could figure out that

Re: [go-nuts] "Craftsman's" Go Generics proposal

2018-09-10 Thread Wojciech S. Czarnecki
On Mon, 10 Sep 2018 15:31:41 -0500 robert engels wrote: > You would probably have simpler code just define an interface Value(), and > a ComplexValue() and two methods… ...and implement it on any single type I wanna sum? No, thanks. I am doing it already in Go1 :) > But even then, you need my pr

Re: [go-nuts] "Craftsman's" Go Generics proposal

2018-09-10 Thread robert engels
I would argue that is not generics code - the fact that you are type checking in the implementation is a problem, and replicating the logic for “each type”. You would probably have simpler code just define an interface Value(), and a ComplexValue() and two methods… But even then, you need my pro