Re: [go-nuts] Equivalence of types declared with equals

2023-06-04 Thread Duncan Harris
Thanks. So the only issue is that maybe the error message is a bit
sub-optimal.

Duncan


On Sun, 4 Jun 2023 at 06:35, Axel Wagner 
wrote:

> That's a type alias, though. Not a type definition.
>
> The real issue is this part of the spec
> :
>
>> Two struct types are identical if they have the same sequence of fields,
>> and if corresponding fields have the same names, and identical types, and
>> identical tags. *Non-exported field names from different packages are
>> always different*.
>>
> So the two `struct{ f string }` are not identical, because they don't have
> the same same sequence of fields with the same names - the two "f" names
> are different, as they are from different packages.
>
>
>
> On Sun, Jun 4, 2023 at 2:19 AM Kurtis Rader  wrote:
>
>> See https://go.dev/ref/spec#Type_definitions and
>> https://go.dev/ref/spec#Type_identity. In particular this statement: "The
>> new type is called a *defined type*. It is different
>>  from any other type, including
>> the type it is created from."
>>
>> On Sat, Jun 3, 2023 at 5:03 PM Duncan Harris  wrote:
>>
>>> Why does this not work?
>>>
>>> https://go.dev/play/p/dodUj441xJS
>>>
>>> Produces the rather strange error message:
>>>
>>> ./prog.go:7:6: cannot use []t{…} (value of type []struct{f string}) as
>>> []struct{f string} value in argument to m.F
>>>
>>> --
>>> 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/396c63a7-4b0c-4f5e-8c0e-a1e45249e247n%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%3DD8xgRUXQxOpzTuubqMg%3DN_m98VMUHGJUhXF4hMNqA8taQ%40mail.gmail.com
>> 
>> .
>>
>

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


Re: [go-nuts] Equivalence of types declared with equals

2023-06-03 Thread 'Axel Wagner' via golang-nuts
And FWIW the reason for that part of the spec is to disallow doing
something like this: https://go.dev/play/p/fS1kIC-SE7z

On Sun, Jun 4, 2023 at 7:35 AM Axel Wagner 
wrote:

> That's a type alias, though. Not a type definition.
>
> The real issue is this part of the spec
> :
>
>> Two struct types are identical if they have the same sequence of fields,
>> and if corresponding fields have the same names, and identical types, and
>> identical tags. *Non-exported field names from different packages are
>> always different*.
>>
> So the two `struct{ f string }` are not identical, because they don't have
> the same same sequence of fields with the same names - the two "f" names
> are different, as they are from different packages.
>
>
>
> On Sun, Jun 4, 2023 at 2:19 AM Kurtis Rader  wrote:
>
>> See https://go.dev/ref/spec#Type_definitions and
>> https://go.dev/ref/spec#Type_identity. In particular this statement: "The
>> new type is called a *defined type*. It is different
>>  from any other type, including
>> the type it is created from."
>>
>> On Sat, Jun 3, 2023 at 5:03 PM Duncan Harris  wrote:
>>
>>> Why does this not work?
>>>
>>> https://go.dev/play/p/dodUj441xJS
>>>
>>> Produces the rather strange error message:
>>>
>>> ./prog.go:7:6: cannot use []t{…} (value of type []struct{f string}) as
>>> []struct{f string} value in argument to m.F
>>>
>>> --
>>> 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/396c63a7-4b0c-4f5e-8c0e-a1e45249e247n%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%3DD8xgRUXQxOpzTuubqMg%3DN_m98VMUHGJUhXF4hMNqA8taQ%40mail.gmail.com
>> 
>> .
>>
>

-- 
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/CAEkBMfFd7kA48VngLJdMXD873vKk_LSUJYk6%2BAC1teyBJQn1mQ%40mail.gmail.com.


Re: [go-nuts] Equivalence of types declared with equals

2023-06-03 Thread 'Axel Wagner' via golang-nuts
That's a type alias, though. Not a type definition.

The real issue is this part of the spec
:

> Two struct types are identical if they have the same sequence of fields,
> and if corresponding fields have the same names, and identical types, and
> identical tags. *Non-exported field names from different packages are
> always different*.
>
So the two `struct{ f string }` are not identical, because they don't have
the same same sequence of fields with the same names - the two "f" names
are different, as they are from different packages.



On Sun, Jun 4, 2023 at 2:19 AM Kurtis Rader  wrote:

> See https://go.dev/ref/spec#Type_definitions and
> https://go.dev/ref/spec#Type_identity. In particular this statement: "The
> new type is called a *defined type*. It is different
>  from any other type, including
> the type it is created from."
>
> On Sat, Jun 3, 2023 at 5:03 PM Duncan Harris  wrote:
>
>> Why does this not work?
>>
>> https://go.dev/play/p/dodUj441xJS
>>
>> Produces the rather strange error message:
>>
>> ./prog.go:7:6: cannot use []t{…} (value of type []struct{f string}) as
>> []struct{f string} value in argument to m.F
>>
>> --
>> 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/396c63a7-4b0c-4f5e-8c0e-a1e45249e247n%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%3DD8xgRUXQxOpzTuubqMg%3DN_m98VMUHGJUhXF4hMNqA8taQ%40mail.gmail.com
> 
> .
>

-- 
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/CAEkBMfGuYUeJ0yyd8UpoY4gpZxHJDc5k7W40bTzNKyLVSz5Gew%40mail.gmail.com.


Re: [go-nuts] Equivalence of types declared with equals

2023-06-03 Thread Kurtis Rader
See https://go.dev/ref/spec#Type_definitions and
https://go.dev/ref/spec#Type_identity. In particular this statement: "The
new type is called a *defined type*. It is different
 from any other type, including the
type it is created from."

On Sat, Jun 3, 2023 at 5:03 PM Duncan Harris  wrote:

> Why does this not work?
>
> https://go.dev/play/p/dodUj441xJS
>
> Produces the rather strange error message:
>
> ./prog.go:7:6: cannot use []t{…} (value of type []struct{f string}) as
> []struct{f string} value in argument to m.F
>
> --
> 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/396c63a7-4b0c-4f5e-8c0e-a1e45249e247n%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%3DD8xgRUXQxOpzTuubqMg%3DN_m98VMUHGJUhXF4hMNqA8taQ%40mail.gmail.com.


[go-nuts] Equivalence of types declared with equals

2023-06-03 Thread Duncan Harris
Why does this not work?

https://go.dev/play/p/dodUj441xJS

Produces the rather strange error message:

./prog.go:7:6: cannot use []t{…} (value of type []struct{f string}) as 
[]struct{f string} value in argument to m.F

-- 
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/396c63a7-4b0c-4f5e-8c0e-a1e45249e247n%40googlegroups.com.