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 with slices of interfaces I learn that I have to use the for range loop for converting each element of the interface's slice into the concrete type. I learned it from this article <https://go101.org/article/interface.html> (Look for "Values of []T can't be directly converted to []I, even if type T implements interface type I"). El lun, 23 oct 2023 a las 16:59, Mike Schinkel (<m...@newclarity.net>) escribió: > 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, regarding your *"I mean this... > <https://goplay.tools/snippet/GCxBeHMfipf>"* link, I already addressed > <https://groups.google.com/g/golang-nuts/c/eD7207kM8zA/m/IZSZNPwnAQAJ> > why that was not sufficient for the use-case earlier in the thread. #justfyi > > On Monday, October 23, 2023 at 2:20:28 PM UTC-4 Victor Giordano wrote: > >> 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... this also happens >> with typescript... perhaps is a common trait in evolution of language >> compilers. >> >> Now if you allow me, I do appreciate that not using generics and using >> interfaces in your Append method things will work... I mean this >> <https://goplay.tools/snippet/GCxBeHMfipf>... >> I know... probably it won't fit to your coding issues... but what I feel >> sometimes is that generics aren't necessary and we tend to make use. I >> don't know.. forgive me if I'm wrong... just an opinion. >> >> >> El lunes, 23 de octubre de 2023 a las 0:01:47 UTC-3, tapi...@gmail.com >> escribió: >> >>> On Monday, October 23, 2023 at 10:38:59 AM UTC+8 tapi...@gmail.com >>> wrote: >>> >>> Sorry, I didn't look your full code. >>> I think the full code should work with Go toolchain 1.21.n. >>> >>> >>> Aha, it actually doesn't. I'm surprised. >>> >>> >>> On Sunday, October 22, 2023 at 4:40:55 PM UTC+8 Mike Schinkel wrote: >>> >>> How so? >>> >>> Can you give an example scenario where it could cause unintended >>> consequences? Or some other negative? >>> >>> -Mike >>> >>> On Saturday, October 21, 2023 at 11:57:52 PM UTC-4 tapi...@gmail.com >>> wrote: >>> >>> >>> It is hard to call such type inference better. That is too aggressive. >>> >>> -- > You received this message because you are subscribed to a topic in the > Google Groups "golang-nuts" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/golang-nuts/eD7207kM8zA/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/c62243c1-d6af-41c1-b64d-be7d59063576n%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/c62243c1-d6af-41c1-b64d-be7d59063576n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- V -- 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 golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAPUu9ssfAUU%2BKQmF%3D4fo9KoTuj6%2BhAQQ5zQzs4Xr_KE47iuKnQ%40mail.gmail.com.