Re: [go-nuts] [generics] Why is constraint optional?

2020-06-17 Thread eric fang
> > It seems annoying to force > everyone to write interface{} all the time when it is normally not > needed. > I agree, omitting interface{} should not cause much trouble to the parser. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] [generics] Why is constraint optional?

2020-06-17 Thread Ian Lance Taylor
On Wed, Jun 17, 2020 at 4:19 AM Hal wrote: > > "If a constraint is specified for any type parameter, every type parameter > must have a constraint. If some type parameters need a constraint and some do > not, those that do not should have a constraint of interface{}." > > "interface{}" equals

Re: [go-nuts] [generics] Why is constraint optional?

2020-06-17 Thread 'Axel Wagner' via golang-nuts
On Wed, Jun 17, 2020 at 1:19 PM Hal wrote: > * the syntax defining generic function is verbose on purpose (type > keyword), not only for clarification, but also a remind of the cost and > complexity behind generics > I don't know where this idea is from, but it's not accurate. The type keyword

[go-nuts] [generics] Why is constraint optional?

2020-06-17 Thread Hal
"If a constraint is specified for any type parameter, every type parameter must have a constraint. If some type parameters need a constraint and some do not, those that do not should have a constraint of interface{}." "interface{}" equals to "Any Type" in the context of generics. So it seems