Re: [go-nuts] Can Generics match implementers of an interface?

2023-10-23 Thread Victor Giordano
TD;DR; Erratas: I mean, I got all the genericity (not "generosity") I need (without "I shall") I'm sorry and please accept the amendment. El lun, 23 oct 2023 a las 18:21, Victor Giordano () escribió: > Yes Ineed Mike! Generics can be good and can be bad... perhaps just as the > OOP inheritance.

Re: [go-nuts] Can Generics match implementers of an interface?

2023-10-23 Thread Victor Giordano
Yes Ineed Mike! Generics can be good and can be bad... perhaps just as the OOP inheritance. And thanks Alex indeed! His answer was enlightening! TD;DR; Just another personal feeling. Prior to generics: with interfaces I live a happy life, I got all the generosity I shall need... if I wanna work

Re: [go-nuts] Can Generics match implementers of an interface?

2023-10-23 Thread Mike Schinkel
Absolutely, some times generics are not needed. I actually don't find a need to use them that often which is probably why when I came across a use-case that really needed them I was so stumped as to how make it work. Kudos again to Axel for helping me recognize my blindspot. -Mike P.S. BTW,

Re: [go-nuts] Can Generics match implementers of an interface?

2023-10-23 Thread Mike Schinkel
Yes, I was surprised too. It actually took me the better part of a day trying to get this to work before finally posting to the list. It turns out that this limit was actually documented by Ian Lance Taylor back in February 2023: https://github.com/golang/go/issues/58650 Look for the section

Re: [go-nuts] Can Generics match implementers of an interface?

2023-10-23 Thread Victor Giordano
Very interesting case. As Alex says, if you "help" the compiler writing the actual type parameter like `Append[Suiter](slice, suiter)` it works. I have seen this before in Java when generics comes into town... I guess with time golang team with time will improve the type inference engine... th

Re: [go-nuts] Re: custom slog Handler which adds Attribute and WithGroup

2023-10-23 Thread 'Sean Liao' via golang-nuts
The slog API doesn't allow wrapping handlers this way. slog.Handlers hold state for the current open group. You'll need a full implementation of a handler to do this. (Technically it's possible if you record the group/attrs in With/WithGroup yourself and only call the wrapped handler in Handle, bu

[go-nuts] Can a lambda passed to other functions be inlined by a Go compiler?

2023-10-23 Thread Shamil Mukhetdinov
Imagine you have something like this: * func foo(data []int, suitable func(v int) bool) []int { * * result := make([]int, 0, len(data) * *for _, v := range data { * *if suitable(v) { * *result = append(result, v) * *} * *} return result * *} * func main() {

Re: [go-nuts] Re: recommended statistics package? Requirements: ANOVA, Brown-Forsythe

2023-10-23 Thread Martin Schnabel
Hi, I attempted to translate the linked JS implementation for fun. Maybe someone can use it as a starting point and correct or verify its correctness. https://go.dev/play/p/Wrw2yDRof0z Have fun! On 10/23/23 07:38, Jan wrote: hi, I did a quick search and I didn't find anything in Go. But loo

[go-nuts] Re: custom slog Handler which adds Attribute and WithGroup

2023-10-23 Thread Johann Höchtl
As I got zero reply to that answer, let me rephrase it probably more easily: I would like to use slog, no other logging library I would like to have an entry called eventID which is at the root level and has a unique uuid for every log entry I would like to use a group for every application speci

[go-nuts] Go called by C: is the goroutine locked to a thread?

2023-10-23 Thread Domenico Andreoli
Hi, I'm writing a Go library to embed/extend CPython (Pygolo ). CPython uses thread local storage and therefore I need to care about pinning goroutines to OS threads accordingly. It's pretty much clear that when the Python interpreter is embedded it can be acces