Re: [go-nuts] Upcasting/Downcasting in Go

2017-11-09 Thread Konstantin Khomoutov
On Wed, Nov 08, 2017 at 02:48:06PM -0800, Ian Lance Taylor wrote: [...] >> So when should I expect the type casting to work? [...] > When thinking about Go it's best to avoid concepts that do not apply, > like derived class, upcast, and downcast. You can't write > d.testUnderlyingTypeAsReceiver()

Re: [go-nuts] Upcasting/Downcasting in Go

2017-11-08 Thread Ian Lance Taylor
On Wed, Nov 8, 2017 at 1:39 PM, Haiyu Zhen wrote: > > As someone who is new to Golang world, I am confused with the following > code. > > As sample code shown, type S's "underlying" type is slice (in C++ jargon S > is the derived class of slice), and if I pass a slice as S in function > parameter,

[go-nuts] Upcasting/Downcasting in Go

2017-11-08 Thread Haiyu Zhen
As someone who is new to Golang world, I am confused with the following code. As sample code shown, type S's "underlying" type is slice (in C++ jargon S is the derived class of slice), and if I pass a slice as S in function parameter, it works; but if I pass slice as S in function receiver, Go