Re: [go-nuts] Unhappy with the official generics tutorial

2024-02-22 Thread 'Carla Pfaff' via golang-nuts
On Thursday 22 February 2024 at 10:19:58 UTC+1 Jan Mercl wrote:

On Thu, Feb 22, 2024 at 10:06 AM 'Carla Pfaff' via golang-nuts 
 wrote: 

> This omission is notable considering "any" is among the most frequently 
used constraints in writing generic code. 

Interesting to know, I'd naively guess the opposite. Can you please 
share the source data set? Thank you.


In the standard library, the most notable packages that add generic 
functions are slices  and maps 
. Almost all of their functions feature an 'any' 
constraint. Same for other generic additions to the standard library such 
as atomic.Pointer, reflect.TypeFor, and sync.OnceValue.

-- 
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/7e0656cf-876c-4a82-9760-40923261d722n%40googlegroups.com.


Re: [go-nuts] Unhappy with the official generics tutorial

2024-02-22 Thread Jan Mercl
On Thu, Feb 22, 2024 at 10:06 AM 'Carla Pfaff' via golang-nuts
 wrote:

> This omission is notable considering "any" is among the most frequently used 
> constraints in writing generic code.

Interesting to know, I'd naively guess the opposite. Can you please
share the source data set? Thank you.

-- 
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/CAA40n-W2%3DBysk7OHi_OqV%3DM3EO_67JMyy5DjhBEpW7Gaa8FeKw%40mail.gmail.com.


Re: [go-nuts] Unhappy with the official generics tutorial

2024-02-22 Thread 'Carla Pfaff' via golang-nuts
The feedback was not specific to the "SumIntsOrFloats" example in the 
tutorial. The tutorial fails to demonstrate any generic data structures 
utilizing the "[T any]" constraint or a function with an 'any' constraint, 
such as "slices.Clone[S ~[]E, E any](s S) S". This omission is notable 
considering "any" is among the most frequently used constraints in writing 
generic code.

On Thursday 22 February 2024 at 09:10:30 UTC+1 Kurtis Rader wrote:

I don't understand your feedback. How, exactly, should generics handle the 
`any` type? Documentation can always be improved but how would a generic 
function that accepts two `any` types perform addition of those "any" 
values?

 

-- 
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/c9c9e11b-9bf8-4ffd-b75e-ebb491962d63n%40googlegroups.com.


Re: [go-nuts] Unhappy with the official generics tutorial

2024-02-22 Thread Kurtis Rader
I don't understand your feedback. How, exactly, should generics handle the
`any` type? Documentation can always be improved but how would a generic
function that accepts two `any` types perform addition of those "any"
values?

On Thu, Feb 22, 2024 at 12:01 AM 'Carla Pfaff' via golang-nuts <
golang-nuts@googlegroups.com> wrote:

> The Go documentation, available at https://go.dev/doc/, features only one
> tutorial dedicated to generics, found at
> https://go.dev/doc/tutorial/generics. This tutorial lacks any examples
> employing the 'any' constraint, nor does it mention it. Instead, it begins
> with the use of an 'int64 | float64' constraint. These A|B constraints
> represent a more specialized application of generics, aimed at scenarios
> where there is a need to utilize an operator such as "+". However, the most
> universal, adaptable, and reusable form of a generic type or function — one
> that utilizes 'any' — is notably absent.
>
> --
> 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/0447f6d6-6fe9-410f-9d5a-08bb20bba67en%40googlegroups.com
> 
> .
>


-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

-- 
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/CABx2%3DD9TYR0A5cHfe4FSNnoR5xwY8yhfrJ3P2kLnsCo2bpus6g%40mail.gmail.com.


[go-nuts] Unhappy with the official generics tutorial

2024-02-22 Thread 'Carla Pfaff' via golang-nuts
The Go documentation, available at https://go.dev/doc/, features only one 
tutorial dedicated to generics, found at 
https://go.dev/doc/tutorial/generics. This tutorial lacks any examples 
employing the 'any' constraint, nor does it mention it. Instead, it begins 
with the use of an 'int64 | float64' constraint. These A|B constraints 
represent a more specialized application of generics, aimed at scenarios 
where there is a need to utilize an operator such as "+". However, the most 
universal, adaptable, and reusable form of a generic type or function — one 
that utilizes 'any' — is notably absent.

-- 
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/0447f6d6-6fe9-410f-9d5a-08bb20bba67en%40googlegroups.com.