Yeah, me too, preferring the first version, which I've archived as a masterpiece at https://github.com/suntong/lang/blob/master/lang/Go/src/oo/Polymorphism-AnimalVF3.go with the following notes:
The best way to implement *virtual function* so far, that satisfies the following challenges: - Consider the "func Output()" as a *very complicated* function that I only want to define once at the base level, not to duplicate into each sub classes, yet it need to access member functions from sub classes. - Meanwhile I have a *huge list* of common variables that I defined in my "base class", and using simple pure function will cause almost every single variable to be undefined: https://play.golang.org/p/QjCtD9rGpa On Thu, Nov 24, 2016 at 9:37 PM, xingtao zhao wrote: > Or this implementation: https://play.golang.org/p/5GqspHDJnF > But I prefer the previous version: https://play.golang.org/p/3_PDTCcJTi. > > > On Thursday, November 24, 2016 at 6:21:24 PM UTC-8, xingtao zhao wrote: >> >> Hi Tong, >> >> Another implementation is https://play.golang.org/p/3_PDTCcJTi. >> You could merge the interface Animal and ExtraFactsor together if this >> extra behavior is not needed. It is listed there just for demonstration. >> > -- 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. For more options, visit https://groups.google.com/d/optout.