[go-nuts] Re: Inheritance and OOP: Go one better

2018-02-13 Thread Matt Ho
I’m not sure how an interface doesn’t satisfy what you’re looking for.  Can you 
describe your use case in a little more detail?

-- 
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.


[go-nuts] Re: Inheritance and OOP: Go one better

2018-02-13 Thread Stefan Nilsson
My goal is a different one. I'm trying to figure out how to best use the 
features of Go for code reuse and dynamic method dispatch _without_ 
inheritance.

Inheritance is a pretty strange language construct. It combines several 
different features in one. In my experience it's rare that all of these are 
needed at the same time and in this particular combination. I very much 
prefer to use the more basic and orthogonal features in Go: composition, 
embedding and interfaces.

On Tuesday, February 13, 2018 at 10:23:39 AM UTC+1, Haddock wrote:
>
> Hi Stefan,
>
> your solution falls short on addressing the underlying problem of how to 
> implement inheritance using dynamic dispatch through using interface. In 
> the article "Inner Pattern to mimic Method Overwriting in Go 
> " 
> there is a section with the headline "Motivation" where it says:
>
> This means that "f.MoreMagic()" in the last line in the code snippet below 
> (sample shamelessly stolen from [2 
> ])
>  
> does not print "foo magic" to the console as expected but "base magic".
>
> You can have a look at that article as it shows a solution how to get 
> accomplished what you were trying to do.
>
> Am Donnerstag, 8. Februar 2018 17:47:04 UTC+1 schrieb Stefan Nilsson:
>>
>> Here is a short article about how to do OOP in Go with composition, 
>> structurally typed interfaces and, in some special cases, embedding. I 
>> believe this can often be a better approach than traditional OOP modeling 
>> using inheritance. I'd love to hear you thoughts.
>>
>> Inheritance and OOP: Go one better 
>> 
>>
>

-- 
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.


Re: [go-nuts] Re: Inheritance and OOP: Go one better

2018-02-13 Thread Jesper Louis Andersen
On Thu, Feb 8, 2018 at 6:53 PM  wrote:

> Closures and function types/fields may have a place in discussing OOP-like
> Go constructs.
>
>
Yes! One can implement roughly any feature of the OO crowd with closures
and types. Although it can be far more verbose to do so in the language.

-- 
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.


[go-nuts] Re: Inheritance and OOP: Go one better

2018-02-13 Thread Haddock
Hi Stefan,

your solution falls short on addressing the underlying problem of how to 
implement inheritance using dynamic dispatch through using interface. In 
the article "Inner Pattern to mimic Method Overwriting in Go 
" 
there is a section with the headline "Motivation" where it says:

This means that "f.MoreMagic()" in the last line in the code snippet below 
(sample shamelessly stolen from [2 
])
 
does not print "foo magic" to the console as expected but "base magic".

You can have a look at that article as it shows a solution how to get 
accomplished what you were trying to do.

Am Donnerstag, 8. Februar 2018 17:47:04 UTC+1 schrieb Stefan Nilsson:
>
> Here is a short article about how to do OOP in Go with composition, 
> structurally typed interfaces and, in some special cases, embedding. I 
> believe this can often be a better approach than traditional OOP modeling 
> using inheritance. I'd love to hear you thoughts.
>
> Inheritance and OOP: Go one better 
> 
>

-- 
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.


[go-nuts] Re: Inheritance and OOP: Go one better

2018-02-08 Thread matthewjuran
Closures and function types/fields may have a place in discussing OOP-like 
Go constructs.

Matt

On Thursday, February 8, 2018 at 10:47:04 AM UTC-6, Stefan Nilsson wrote:
>
> Here is a short article about how to do OOP in Go with composition, 
> structurally typed interfaces and, in some special cases, embedding. I 
> believe this can often be a better approach than traditional OOP modeling 
> using inheritance. I'd love to hear you thoughts.
>
> Inheritance and OOP: Go one better 
> 
>

-- 
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.