Re: [go-nuts] Generic "nillable" constraint

2023-10-01 Thread Patrick Smith
A quick correction to my own comment: On Sun, Oct 1, 2023 at 8:35 PM Patrick Smith wrote: > The problem with your code is that "T comparable" guarantees that two > values of type T can be compared, > ... but then I remembered the comparison can still panic at runtime, as per https://go.dev/doc/

Re: [go-nuts] Generic "nillable" constraint

2023-10-01 Thread Patrick Smith
On Sun, Oct 1, 2023 at 7:30 PM Jon Watte wrote: > I want to implement a generic function to "remove nil values from a > slice." This should be able to remove nil instances of error, for example. > So, let's say I have: > > var arg = []error{nil, errors.New("oh noes"), nil} > > Unfortunately, this

Re: [go-nuts] Generic "nillable" constraint

2023-10-01 Thread Jon Watte
> It seems to me `== nil` is a better way to spell that, than a function call. And a generic function can always do `v == *new(T)` to check if a value is the zero value. Bringing this up because I found it from a thread on Google. I want to implement a generic function to "remove nil values fr

Re: [go-nuts] What is a ordinary and exceptional error?

2023-10-01 Thread Kamil Ziemian
Axel Wagner, you opinin is highly appriciated. niedziela, 1 października 2023 o 15:00:35 UTC+2 Axel Wagner napisał(a): > On Sun, Oct 1, 2023 at 2:37 PM Jerry Londergaard > wrote: > >> I've been thinking about this point as well lately. I think I understand >> (at least some of) the conditions

Re: [go-nuts] Re: Is it expected that signal.NotifyContext() changes the execution thread?

2023-10-01 Thread TheDiveO
Weeell, I had unit tests running without hiccup on a wide range of devices, and only a year later some of them started to fail with a seemingly "leaked" (non-restored) namespace. The question here and the suggested issue then introduced me to the "wedged" M0 thread. It works until it doesn'

Re: [go-nuts] About variables have per-iteration scope instead of per-loop scope

2023-10-01 Thread Victor Giordano
> In Go, so far changes were for the better and I'm glad to change my learning if it benefits the mass of my fellow developers. Maybe. Let's see how times handle it. TD;DR; I praise for changes but it is not easy.. I mean, look at our society (the final reflection of us as an unique aggregated

Re: [go-nuts] What is a ordinary and exceptional error?

2023-10-01 Thread 'Axel Wagner' via golang-nuts
On Sun, Oct 1, 2023 at 2:37 PM Jerry Londergaard wrote: > I've been thinking about this point as well lately. I think I understand > (at least some of) the conditions under which > you would call a panic(), but I still don't quite grok why it's better > than returning an error if that error is pr

Re: [go-nuts] What is a ordinary and exceptional error?

2023-10-01 Thread Jerry Londergaard
I've been thinking about this point as well lately. I think I understand (at least some of) the conditions under which you would call a panic(), but I still don't quite grok why it's better than returning an error if that error is properly handled. If I panic(), then no defer() statements will

Re: [go-nuts] When to share an interface, and when not to.

2023-10-01 Thread Jerry Londergaard
Thanks Burak. I think that makes sense. You can perhaps still think of that approach as defining the interface "where it's used", even if it's not quite as close to where it's used as is technically possible. It still has its caveats, but it does seem better than defining it where it's implemented

Re: [go-nuts] About variables have per-iteration scope instead of per-loop scope

2023-10-01 Thread TheDiveO
actually, language changes happen all the time. In German, there is quite some "misuse" esp. by journos that change or follow change in German, not necessarily improving clearness. In Go, so far changes were for the better and I'm glad to change my learning if it benefits the mass of my fellow