Re: [go-nuts] promoted methods confusion

2021-02-23 Thread Volker Dobler
On Tuesday, 23 February 2021 at 07:01:27 UTC+1 Henry wrote: > I think the problem is that people try to use embedding in place of > inheritance. [...] Embedding shares many similarities to inheritance The first part is a real common problem but I have to admit I do not understand where the se

Re: [go-nuts] promoted methods confusion

2021-02-22 Thread Henry
I think the problem is that people try to use embedding in place of inheritance. You can see that in the original author's example involving Cat, Animal, and Pack. Embedding shares many similarities to inheritance, such as method promotion, but they are not the same. Embedding is in a way more

Re: [go-nuts] promoted methods confusion

2021-02-22 Thread Ian Lance Taylor
On Mon, Feb 22, 2021 at 12:52 PM mi...@ubo.ro wrote: > > Is there any proposal in Go 2.0 to remove the promotion of methods on > embedded struct fields or do you think it's a good idea ? For example in the > code below if someone marshals `Pack`, only `Animal` is actually marshalled. > Cat fiel

[go-nuts] promoted methods confusion

2021-02-22 Thread mi...@ubo.ro
Is there any proposal in Go 2.0 to remove the promotion of methods on embedded struct fields or do you think it's a good idea ? For example in the code below if someone marshals `Pack`, only `Animal` is actually marshalled. Cat field is skipped. If he wants to marshal Cat as well the developer