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

2020-06-18 Thread Hal
Yes, an alternative syntax I can come up with (underscore as a placeholder): func Foo(type T1 _, T2 Bar) On Thursday, 18 June 2020 03:28:39 UTC+1, Andrey Tcherepanov wrote: > > Wouldn't it be nice to have just > > func Foo(type T1, type T2 Bar) > > (type as keyword splitting it into 2 type decla

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

2020-06-17 Thread Andrey Tcherepanov
Wouldn't it be nice to have just func Foo(type T1, type T2 Bar) (type as keyword splitting it into 2 type declarations) On Wednesday, June 17, 2020 at 5:50:47 AM UTC-6, Brian Candler wrote: > > Consider a generic where you want T1 unconstrained but T2 constrained. If > you write > > func Foo(

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

2020-06-17 Thread Brian Candler
Sorry, I understand what you're saying now. I quite like "type T" meaning "any type", but you have a fair point. -- 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

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

2020-06-17 Thread Hǎiliàng Wáng
Hi Brian, Thanks for your reply but I don’t think you get my point, what I mean is constraint should be always explicitly specified, so we should not support “optional” or “omitted” constraints. On Wed, 17 Jun 2020 at 12:51, Brian Candler wrote: > Consider a generic where you want T1 unconstrai

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

2020-06-17 Thread Brian Candler
Consider a generic where you want T1 unconstrained but T2 constrained. If you write func Foo(type T1, T2 Bar) then Bar constrains both. Hence the need for func Foo(type T1 interface{}, T2 Bar) -- You received this message because you are subscribed to the Google Groups "golang-nuts" group.