[go-nuts] Re: Array type parameters?

2022-06-05 Thread Jason Phillips
Not currently. See the "omissions" section of the proposal [1]: > No parameterization on non-type values such as constants. This arises most obviously for arrays, where it might sometimes be convenient to write type Matrix[n int] [n][n]float64. It might also sometimes be useful to specify signi

[go-nuts] Array type parameters?

2022-06-05 Thread Amit Lavon
Hi, Is it possible to set a generic type parameter of "T array of any size" (not slice)? Something like: func foo[A [...]T, T constraints.Integer](a A) { m := map[A]string{} ... } -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscrib

Re: [go-nuts] Nil could be the zero value for type variables

2022-06-05 Thread Nigel Tao
On Tue, May 31, 2022 at 1:39 AM Will Faught wrote: > Why not allow nil to be used as the zero value for type variables, to fill > this gap? > > return nil // == V(nil) > See also: https://github.com/golang/go/issues/35966 https://github.com/golang/go/issues/19642 -- You received this message b

Re: [go-nuts] How Unbuffered channel work

2022-06-05 Thread Manjeet S
Thank you so much Aleksei Perevozov and Jan Mercl On Sunday, June 5, 2022 at 7:49:40 PM UTC+5:30 Jan Mercl wrote: > On Sun, Jun 5, 2022 at 4:06 PM Manjeet S wrote: > > > Can someone help me to understand why this code is not working. I'm > expecting that <-ch wait until we receive from channe

Re: [go-nuts] How Unbuffered channel work

2022-06-05 Thread Jan Mercl
On Sun, Jun 5, 2022 at 4:06 PM Manjeet S wrote: > Can someone help me to understand why this code is not working. I'm expecting > that <-ch wait until we receive from channel ch The range statement at line 18 does not complete unless the channel is closed. Adding `close(ch2)` at line 14 fixes t

[go-nuts] Re: How Unbuffered channel work

2022-06-05 Thread pere...@gmail.com
You did not close ch2 in the first goroutine. Therefore, the second goroutine never reaches line "ch <- struct{}{}" Aleksei Perevozov воскресенье, 5 июня 2022 г. в 16:06:53 UTC+2, manjee...@gmail.com: > I just started to learn Go Language, and I'm enjoying writing code in Go. > So today, I'm tr

[go-nuts] How Unbuffered channel work

2022-06-05 Thread Manjeet S
I just started to learn Go Language, and I'm enjoying writing code in Go. So today, I'm trying to understand how the unbuffered channel works Can someone help me to understand why this code is not working. I'm expecting that <-ch wait until we receive from channel ch func main() { ch := mak