Re: [go-nuts] Link: Getting specific about generics

2018-09-04 Thread roger peppe
On Tue, 4 Sep 2018, 5:52 pm xingtao zhao, wrote: My five cents: 1) the methods of the type template are defined by interface style 2) operators are retrieved implicitly from function body 3) function-calls inside are also retrieved implicitly from the function body For graph example, we may dec

Re: [go-nuts] Link: Getting specific about generics

2018-09-04 Thread Steven Blenkinsop
On Tuesday, September 4, 2018 at 6:07:32 PM UTC-4, xingtao zhao wrote: > I was assume that generic interfaces are allowed, which we do not need > "self" type. This is *not* equivalent. If you have an interface defined as type Fooer(type T) interface { Foo() T } this corresponds to a

Re: [go-nuts] Link: Getting specific about generics

2018-09-04 Thread xingtao zhao
On Tuesday, September 4, 2018 at 2:26:58 PM UTC-7, Steven Blenkinsop wrote: > > If we try to translate contracts into interfaces, the first thing we run > into is that there's no way to refer to the dynamic type of the interface. > Compare: > > > > contract Fooer(t T) { > > interface{ Fo

Re: [go-nuts] Link: Getting specific about generics

2018-09-04 Thread Steven Blenkinsop
If we try to translate contracts into interfaces, the first thing we run into is that there's no way to refer to the dynamic type of the interface. Compare: contract Fooer(t T) { interface{ Foo() T }(t) } to type Fooer interface { Foo() ??? } There would have to be some so

Re: [go-nuts] Link: Getting specific about generics

2018-09-04 Thread xingtao zhao
On Tuesday, September 4, 2018 at 9:52:07 AM UTC-7, xingtao zhao wrote: > > My five cents: > > 1) the methods of the type template are defined by interface style > 2) operators are retrieved implicitly from function body > 3) function-calls inside are also retrieved implicitly from the function >

Re: [go-nuts] Link: Getting specific about generics

2018-09-04 Thread xingtao zhao
My five cents: 1) the methods of the type template are defined by interface style 2) operators are retrieved implicitly from function body 3) function-calls inside are also retrieved implicitly from the function body For graph example, we may declare it as: type Edgeser(type E) interface {

Re: [go-nuts] Link: Getting specific about generics

2018-09-03 Thread Ian Lance Taylor
On Sun, Sep 2, 2018 at 1:08 AM, 'Charlton Trezevant' via golang-nuts wrote: > > Link: [Getting specific about generics, by Emily > Maier](https://emilymaier.net/words/getting-specific-about-generics/) > > The interface-based alternative to contracts seems like such a natural fit- > It’s simple, st

Re: [go-nuts] Link: Getting specific about generics

2018-09-02 Thread Bakul Shah
> On Sep 2, 2018, at 3:19 PM, roger peppe wrote: > > > > On Sun, 2 Sep 2018, 5:09 pm Bakul Shah, > wrote: > People may find this excellent paper “Datatype-Generic Programming” by Jeremy > Gibbons useful in this discussion. It’s 72 pages long. > https://www.cs.ox

Re: [go-nuts] Link: Getting specific about generics

2018-09-02 Thread roger peppe
On Sun, 2 Sep 2018, 5:09 pm Bakul Shah, wrote: > People may find this excellent paper “Datatype-Generic Programming” by > Jeremy Gibbons useful in this discussion. It’s 72 pages long. > https://www.cs.ox.ac.uk/jeremy.gibbons/publications/dgp.pdf > > I want generics but I still don’t know if I lik

Re: [go-nuts] Link: Getting specific about generics

2018-09-02 Thread Bakul Shah
People may find this excellent paper “Datatype-Generic Programming” by Jeremy Gibbons useful in this discussion. It’s 72 pages long. https://www.cs.ox.ac.uk/jeremy.gibbons/publications/dgp.pdf I want generics but I still don’t know if I like this go2 generics proposal. At least as an exercise i

Re: [go-nuts] Link: Getting specific about generics

2018-09-02 Thread Sebastien Binet
Hi, On Sun, Sep 2, 2018, 12:55 haskell_mustard via golang-nuts < golang-nuts@googlegroups.com> wrote: > I prefer seeing the contract by example over having a combination of two > dozens of interface names like Eq, Lesser, Adder, Muler, Convertible(x), > Ranger, Lener, Caper, ... that have to be m

Re: [go-nuts] Link: Getting specific about generics

2018-09-02 Thread haskell_mustard via golang-nuts
I prefer seeing the contract by example over having a combination of two dozens of interface names like Eq, Lesser, Adder, Muler, Convertible(x), Ranger, Lener, Caper, ... that have to be mentally mapped to their actual syntactic representation. This smells like taxonomy ("the lowest form of ac

Re: [go-nuts] Link: Getting specific about generics

2018-09-02 Thread Tristan Colgate
It's a great read, clarified stuff for me. An approach that embraces interfaces feels preferable to me. On Sun, 2 Sep 2018, 09:09 'Charlton Trezevant' via golang-nuts, < golang-nuts@googlegroups.com> wrote: > Link: [Getting specific about generics, by Emily Maier]( > https://emilymaier.net/words

[go-nuts] Link: Getting specific about generics

2018-09-02 Thread 'Charlton Trezevant' via golang-nuts
Link: [Getting specific about generics, by Emily Maier](https://emilymaier.net/words/getting-specific-about-generics/) The interface-based alternative to contracts seems like such a natural fit- It’s simple, straightforward, and pragmatic. I value those aspects of Go’s philosophy and consider t