Re: [go-nuts] question about func type

2017-07-05 Thread 'Axel Wagner' via golang-nuts
Orthogonality means (roughly) "independent" in this context. I do agree with you, though, that the slide is incorrect. The spec defines type literals in the TypeLit production (search in page), which clearly only refers to composite types. The slides shouldn't talk

Re: [go-nuts] question about func type

2017-07-05 Thread Jan Mercl
On Wed, Jul 5, 2017 at 11:39 AM Darren Hoo wrote: > In https://talks.golang.org/2015/tricks.slide#5 says int is type literal, then you say int is named type. > > How can int be both type literal and named type while they are orthogonal? A type literal can be a named type

Re: [go-nuts] question about func type

2017-07-05 Thread Darren Hoo
On Wed, Jul 5, 2017 at 5:27 PM, Jan Mercl <0xj...@gmail.com> wrote: > On Wed, Jul 5, 2017 at 11:03 AM Darren Hoo wrote: > > >>> what is the relation between `type literal` and `named type`, > >> > >> Orthogonality. > > > > Then `int` is not named type. > > Please explain

Re: [go-nuts] question about func type

2017-07-05 Thread Jan Mercl
On Wed, Jul 5, 2017 at 11:03 AM Darren Hoo wrote: >>> what is the relation between `type literal` and `named type`, >> >> Orthogonality. > > Then `int` is not named type. Please explain why do you think so. I don't get it. > `int` and `int64` are not the same in this

Re: [go-nuts] question about func type

2017-07-05 Thread Darren Hoo
On Wed, Jul 5, 2017 at 5:06 PM, Jan Mercl <0xj...@gmail.com> wrote: > On Wed, Jul 5, 2017 at 11:03 AM Darren Hoo wrote: > > > what is the relation between `type literal` and `named type`, > > Orthogonality. > Then `int` is not named type. `int` and `int64` are not the

Re: [go-nuts] question about func type

2017-07-05 Thread Jan Mercl
On Wed, Jul 5, 2017 at 11:03 AM Darren Hoo wrote: > what is the relation between `type literal` and `named type`, Orthogonality. > aren't they mutually exclusive? No. Otherwise `type T U` would be illegal. -- -j -- You received this message because you are

Re: [go-nuts] question about func type

2017-07-05 Thread Darren Hoo
On Wednesday, July 5, 2017 at 4:40:57 PM UTC+8, Jan Mercl wrote: > > On Wed, Jul 5, 2017 at 10:33 AM Darren Hoo > wrote: > > > So in https://talks.golang.org/2015/tricks.slide#5 > > > > Other examples of type literals are int and []string, > > > > is actually not

Re: [go-nuts] question about func type

2017-07-05 Thread Jan Mercl
On Wed, Jul 5, 2017 at 10:33 AM Darren Hoo wrote: > So in https://talks.golang.org/2015/tricks.slide#5 > > Other examples of type literals are int and []string, > > is actually not correct. The text is completely correct. Type literal is like a type expression. To

Re: [go-nuts] question about func type

2017-07-05 Thread Darren Hoo
Thanks all. I got it. So in https://talks.golang.org/2015/tricks.slide#5 > Other examples of type literals are int and []string, is actually not correct. On Wednesday, July 5, 2017 at 3:59:57 PM UTC+8, Jan Mercl wrote: > > On Wed, Jul 5, 2017 at 9:54 AM Darren Hoo

Re: [go-nuts] question about func type

2017-07-05 Thread Jan Mercl
On Wed, Jul 5, 2017 at 9:54 AM Darren Hoo wrote: > which part did I misunderstand? 'u' and 'int64' are both named types. -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop

Re: [go-nuts] question about func type

2017-07-05 Thread 'Axel Wagner' via golang-nuts
Yes, V is a named type. The name of V is uint64, which is a predeclared identifier. On Wed, Jul 5, 2017 at 9:54 AM, Darren Hoo wrote: > Thank you all! > > But I still don't quite understand why the rule does not apply to the > first case? > > var a2 u = a1 > > x ---> a1 >

Re: [go-nuts] question about func type

2017-07-05 Thread Darren Hoo
Thank you all! But I still don't quite understand why the rule does not apply to the first case? var a2 u = a1 x ---> a1 T ---> u V ---> uint64 V and T has the identical underlying types (ie, uint64) and V is not a named type (literal) . which part did I misunderstand? On Wednesday, July

Re: [go-nuts] question about func type

2017-07-05 Thread Jan Mercl
On Wed, Jul 5, 2017 at 9:17 AM Darren Hoo wrote: > f1's type is func(int), and f2's type is main.f, they are different types, does implicit conversion happen here? It's not a conversion. The rule is about assignability : "x's type

[go-nuts] question about func type

2017-07-05 Thread Dave Cheney
Func types are just regular types so the rules of assignability apply equally to them as any other type. x's type V and T have identical underlying types and at least one of V or T is not a named type. https://golang.org/ref/spec#Assignability -- You received this message because you are

[go-nuts] question about func type

2017-07-05 Thread Darren Hoo
package main type u uint64 type f func(int) func g(x int) { } func main() { var a1 uint64 = 1000 var a2 u = a1 //why this is not OK var f1 func(int) = g var f2 f = f1 //while this is allowed? f2(1) } f1's type is func(int), and f2's type is main.f, they are different types, does implicit