Re: [go-nuts] how to write methods for a generic Matrix[float64 constrained by Addable]?

2023-09-09 Thread 'Jakob Borg' via golang-nuts
Two minor issues; you can’t declare func (m *Matrix[float64]) NanToZero() because we don’t have specialisation, it needs to be func (m *Matrix[T]) NanToZero(), and you can’t have complex as one of the possible types because it’s impossible to convert a complex to a float. https://go.dev/play/p/

Re: [go-nuts] map type conversion

2023-07-18 Thread 'Jakob Borg' via golang-nuts
On 17 Jul 2023, at 14:50, Leonard Mittmann wrote: Yes, but my thought was that it might be possible to do an unsafe conversion as the underlying types are the same. I just have no idea how. https://go.dev/play/p/ViLnLvInv-1 The unsafe conversion appears to work, but it’s unsafe and not obvious

Re: [go-nuts] Various questions about posts from The Go Blog

2023-03-26 Thread 'Jakob Borg' via golang-nuts
On 26 Mar 2023, at 20:01, Kamil Ziemian wrote: But I cannot understand why in the blog post we have in go.mod file require rsc.io/quote v1.5.2 so "rsc.io/quote" is considered direct dependency, while go.mod produced by Go 1.20 give me rsc.io/quote

Re: [go-nuts] Variable Declaration inside infinite loop

2023-01-25 Thread 'Jakob Borg' via golang-nuts
On 25 Jan 2023, at 12:26, Shashwat wrote: > > Is it safe to declare a variable inside an infinite loop ? > > for { > a := 0 > a += 1 > } > > Won't this cause memory allocation in every iteration ? > > As the declared variables will be allocated memory in the stack and not heap > memor