Re: [go-nuts] Correct way to solve slice of interface type problem

2018-10-31 Thread robert engels
If you use interface based design it is repeated through out the code with no 
way to write a performant generic method.

I am not a big fan of ‘reduced lines of code’ creating obscurity the hallmark 
of Go.

In this case I think being able to pass a slice as an read only [] of interface 
makes MORE sense - since if the slice was not read only, in your case you need 
to add another 3 lines to copy the slice back… (and you might even need to do 
some merge/replace code) so a minimum of 6 lines for every method call 
(although if the calls were all of the same interface type, you would only have 
3 at the front and 3 at the end).

It is not a good coding style IMO, and fixing it would be backwards compatible 
and trivial. Sorry but we’ll probably disagree here.

> On Oct 31, 2018, at 11:21 AM, Space A.  wrote:
> 
> It's already trivial 3 lines o code. Readable, light, and simple.
> 
> And it's a question tbh, if topic starter even needs that code, or just a bad 
> implementation.
> 
> 
> среда, 31 октября 2018 г., 18:47:37 UTC+3 пользователь Jake Montgomery 
> написал:
> It is highly likely that when go2 comes out, with generics, it will be 
> trivial to write a ToInterfaceSlice() function that takes a slice of any type 
> T and returns a []interface{}. 
> 
> 
> -- 
> 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 
> .

-- 
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] Correct way to solve slice of interface type problem

2018-10-31 Thread Space A.
It's already trivial 3 lines o code. Readable, light, and simple.

And it's a question tbh, if topic starter even needs that code, or just a 
bad implementation.


среда, 31 октября 2018 г., 18:47:37 UTC+3 пользователь Jake Montgomery 
написал:
>
> It is highly likely that when go2 comes out, with generics, it will be 
> trivial to write a ToInterfaceSlice() function that takes a slice of any 
> type T and returns a []interface{}. 
>
>

-- 
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] Correct way to solve slice of interface type problem

2018-10-31 Thread robert engels
That’s not what I mean - the function that you would be calling now (that takes 
the []interface{}) would probably be generic for performance reasons, so you 
wouldn’t need to do the conversion - with generics a lot of interface based 
code can go away - and probably will as people chase peak performance… :( 

Still, as someone opposed to generics in Go, I would love to see read-only 
slices as parameters, so you could pass a []concrete to a slice of []interface 
efficiently and safely (or []InterfaceA as []InterfaceB) This would more than 
suffice in lieu of generics in my book...


> On Oct 31, 2018, at 10:47 AM, jake6...@gmail.com wrote:
> 
> It is highly likely that when go2 comes out, with generics, it will be 
> trivial to write a ToInterfaceSlice() function that takes a slice of any type 
> T and returns a []interface{}. 
> 
> On Tuesday, October 30, 2018 at 8:35:39 PM UTC-4, Justin Israel wrote:
> 
> 
> On Wed, Oct 31, 2018 at 1:32 PM robert engels > wrote:
> I have argued for a runtime/built-in to do this - it is so common…. (if doing 
> “kind of OO” in Go)
> 
> I would love to have the ability to do it with built-in support, but I feel 
> like it would go against the goals of not wanting to hide complexity. It 
> wouldn't be "free" to do it (as far as I know) and I doubt the Go maintainers 
> want it to hide the copy into the new slice. My 2 cents.
>  
> 
> 
>> On Oct 30, 2018, at 7:30 PM, Justin Israel > wrote:
>> 
>> 
>> 
>> On Wed, Oct 31, 2018 at 11:21 AM > wrote:
>> Hello, everyone.
>> Consider following code:
>> 
>> package main
>> 
>> import "fmt"
>> 
>> type implementation struct {
>> d []int
>> }
>> 
>> func (impl *implementation) getData() interface{} {
>> return impl.d
>> }
>> 
>> type phase struct{}
>> 
>> type data interface {
>> getData() interface{}
>> }
>> 
>> func MakeIntDataPhase() *phase {
>> return {}
>> }
>> 
>> func (p *phase) run(population []data) []data {
>> return nil
>> }
>> 
>> func main() {
>> var population []implementation
>> MyPhase := MakeIntDataPhase()
>> fmt.Println(MyPhase.run(population))
>> 
>> }
>> 
>> When running following code in playground I got following error: 
>> prog.go:30:25: cannot use population (type []implementation) as type []data 
>> in argument to MyPhase.run
>> If I understand correctly it is because slice of interface type cannot be 
>> converted by the compiler to concrete type.
>> 
>> What is correct way in golang to implement functionality that is presented 
>> in the example?
>> When method argument defined using a slice of some interface, how I can pass 
>> it a slice of a concrete type that implements the interface?
>> 
>> You would end up needing to just do   
>> 
>> func (p *phase) run(population {}interface) []data
>> 
>> and then type assert the {}interface into []implementation
>> There isn't a way to directly pass a slice of concrete type to a function 
>> that accepts a slice of interface, unless you first do this:
>> 
>> iface := make([]data, len(population))
>> for i, p := range population {
>> iface[i] = p
>> }
>> MyPhase.run(iface)
>> 
>> Justin
>> 
>> -- 
>> 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...@googlegroups.com <>.
>> For more options, visit https://groups.google.com/d/optout 
>> .
>> 
>> -- 
>> 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...@googlegroups.com <>.
>> For more options, visit https://groups.google.com/d/optout 
>> .
> 
> 
> -- 
> 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 
> .

-- 
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] Correct way to solve slice of interface type problem

2018-10-31 Thread jake6502
It is highly likely that when go2 comes out, with generics, it will be 
trivial to write a ToInterfaceSlice() function that takes a slice of any 
type T and returns a []interface{}. 

On Tuesday, October 30, 2018 at 8:35:39 PM UTC-4, Justin Israel wrote:
>
>
>
> On Wed, Oct 31, 2018 at 1:32 PM robert engels  > wrote:
>
>> I have argued for a runtime/built-in to do this - it is so common…. (if 
>> doing “kind of OO” in Go)
>>
>
> I would love to have the ability to do it with built-in support, but I 
> feel like it would go against the goals of not wanting to hide complexity. 
> It wouldn't be "free" to do it (as far as I know) and I doubt the Go 
> maintainers want it to hide the copy into the new slice. My 2 cents.
>  
>
>>
>>
>> On Oct 30, 2018, at 7:30 PM, Justin Israel > > wrote:
>>
>>
>>
>> On Wed, Oct 31, 2018 at 11:21 AM > 
>> wrote:
>>
>>> Hello, everyone.
>>> Consider following code:
>>>
>>> package main
>>> import "fmt"
>>>
>>> type implementation struct {
>>> d []int}
>>>
>>> func (impl *implementation) getData() interface{} {
>>> return impl.d}
>>>
>>> type phase struct{}
>>>
>>> type data interface {
>>> getData() interface{}}
>>>
>>> func MakeIntDataPhase() *phase {
>>> return {}}
>>>
>>> func (p *phase) run(population []data) []data {
>>> return nil}
>>>
>>> func main() {
>>> var population []implementation
>>> MyPhase := MakeIntDataPhase()
>>> fmt.Println(MyPhase.run(population))
>>> }
>>>
>>>
>>> When running following code in playground I got following error: 
>>> prog.go:30:25: cannot use population (type []implementation) as type []data 
>>> in argument to MyPhase.run
>>>
>>> If I understand correctly it is because slice of interface type cannot be 
>>> converted by the compiler to concrete type.
>>>
>>>
>>> What is correct way in golang to implement functionality that is presented 
>>> in the example?
>>>
>>> When method argument defined using a slice of some interface, how I can 
>>> pass it a slice of a concrete type that implements the interface?
>>>
>>>
>> You would end up needing to just do   
>>
>> func (p *phase) run(population {}interface) []data
>>
>> and then type assert the {}interface into []implementation
>> There isn't a way to directly pass a slice of concrete type to a function 
>> that accepts a slice of interface, unless you first do this:
>>
>> iface := make([]data, len(population))
>> for i, p := range population {
>> iface[i] = p
>> }
>> MyPhase.run(iface)
>>
>> Justin
>>
>>>
>>> -- 
>>> 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...@googlegroups.com .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> -- 
>> 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...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>>

-- 
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] Correct way to solve slice of interface type problem

2018-10-30 Thread robert engels
I had some previous discussions on another site :) where I suggested that when 
passing a slice to a method, and the method expects an interface, that the 
actual struct parameter is marked as “this is concrete type T but treat as 
interface”, etc. It really only works when the slice is “read only”, but there 
have been similar issues when using generic arrays in Java - you need to know 
that the underlying array MAY be of a different concrete type, so you can’t 
store arbitrary structs in it (if it is read-only you don’t need to worry about 
this).

It would be check - although each access would have another layer of 
indirection - but no different than accessing a slice that contains interfaces 
to begin with.

I think it gets handled - mostly - if generics are added - but I think a simple 
solution now would be good IMO...

> On Oct 30, 2018, at 7:35 PM, Justin Israel  wrote:
> 
> 
> 
> On Wed, Oct 31, 2018 at 1:32 PM robert engels  > wrote:
> I have argued for a runtime/built-in to do this - it is so common…. (if doing 
> “kind of OO” in Go)
> 
> I would love to have the ability to do it with built-in support, but I feel 
> like it would go against the goals of not wanting to hide complexity. It 
> wouldn't be "free" to do it (as far as I know) and I doubt the Go maintainers 
> want it to hide the copy into the new slice. My 2 cents.
>  
> 
> 
>> On Oct 30, 2018, at 7:30 PM, Justin Israel > > wrote:
>> 
>> 
>> 
>> On Wed, Oct 31, 2018 at 11:21 AM > > wrote:
>> Hello, everyone.
>> Consider following code:
>> 
>> package main
>> 
>> import "fmt"
>> 
>> type implementation struct {
>> d []int
>> }
>> 
>> func (impl *implementation) getData() interface{} {
>> return impl.d
>> }
>> 
>> type phase struct{}
>> 
>> type data interface {
>> getData() interface{}
>> }
>> 
>> func MakeIntDataPhase() *phase {
>> return {}
>> }
>> 
>> func (p *phase) run(population []data) []data {
>> return nil
>> }
>> 
>> func main() {
>> var population []implementation
>> MyPhase := MakeIntDataPhase()
>> fmt.Println(MyPhase.run(population))
>> 
>> }
>> 
>> When running following code in playground I got following error: 
>> prog.go:30:25: cannot use population (type []implementation) as type []data 
>> in argument to MyPhase.run
>> If I understand correctly it is because slice of interface type cannot be 
>> converted by the compiler to concrete type.
>> 
>> What is correct way in golang to implement functionality that is presented 
>> in the example?
>> When method argument defined using a slice of some interface, how I can pass 
>> it a slice of a concrete type that implements the interface?
>> 
>> You would end up needing to just do   
>> 
>> func (p *phase) run(population {}interface) []data
>> 
>> and then type assert the {}interface into []implementation
>> There isn't a way to directly pass a slice of concrete type to a function 
>> that accepts a slice of interface, unless you first do this:
>> 
>> iface := make([]data, len(population))
>> for i, p := range population {
>> iface[i] = p
>> }
>> MyPhase.run(iface)
>> 
>> Justin
>> 
>> -- 
>> 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 
>> .
>> 
>> -- 
>> 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 
>> .
> 
> 
> -- 
> 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 
> .

-- 
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] Correct way to solve slice of interface type problem

2018-10-30 Thread Space A.
it's pointer that implements, so
iface[i] = 

среда, 31 октября 2018 г., 3:30:26 UTC+3 пользователь Justin Israel написал:
>
>
>
> On Wed, Oct 31, 2018 at 11:21 AM > wrote:
>
>> Hello, everyone.
>> Consider following code:
>>
>> package main
>> import "fmt"
>>
>> type implementation struct {
>> d []int}
>>
>> func (impl *implementation) getData() interface{} {
>> return impl.d}
>>
>> type phase struct{}
>>
>> type data interface {
>> getData() interface{}}
>>
>> func MakeIntDataPhase() *phase {
>> return {}}
>>
>> func (p *phase) run(population []data) []data {
>> return nil}
>>
>> func main() {
>> var population []implementation
>> MyPhase := MakeIntDataPhase()
>> fmt.Println(MyPhase.run(population))
>> }
>>
>>
>> When running following code in playground I got following error: 
>> prog.go:30:25: cannot use population (type []implementation) as type []data 
>> in argument to MyPhase.run
>>
>> If I understand correctly it is because slice of interface type cannot be 
>> converted by the compiler to concrete type.
>>
>>
>> What is correct way in golang to implement functionality that is presented 
>> in the example?
>>
>> When method argument defined using a slice of some interface, how I can pass 
>> it a slice of a concrete type that implements the interface?
>>
>>
> You would end up needing to just do   
>
> func (p *phase) run(population {}interface) []data
>
> and then type assert the {}interface into []implementation
> There isn't a way to directly pass a slice of concrete type to a function 
> that accepts a slice of interface, unless you first do this:
>
> iface := make([]data, len(population))
> for i, p := range population {
> iface[i] = p
> }
> MyPhase.run(iface)
>
> Justin
>
>> -- 
>> 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...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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] Correct way to solve slice of interface type problem

2018-10-30 Thread Justin Israel
On Wed, Oct 31, 2018 at 1:32 PM robert engels  wrote:

> I have argued for a runtime/built-in to do this - it is so common…. (if
> doing “kind of OO” in Go)
>

I would love to have the ability to do it with built-in support, but I feel
like it would go against the goals of not wanting to hide complexity. It
wouldn't be "free" to do it (as far as I know) and I doubt the Go
maintainers want it to hide the copy into the new slice. My 2 cents.


>
>
> On Oct 30, 2018, at 7:30 PM, Justin Israel  wrote:
>
>
>
> On Wed, Oct 31, 2018 at 11:21 AM  wrote:
>
>> Hello, everyone.
>> Consider following code:
>>
>> package main
>> import "fmt"
>>
>> type implementation struct {
>> d []int}
>>
>> func (impl *implementation) getData() interface{} {
>> return impl.d}
>>
>> type phase struct{}
>>
>> type data interface {
>> getData() interface{}}
>>
>> func MakeIntDataPhase() *phase {
>> return {}}
>>
>> func (p *phase) run(population []data) []data {
>> return nil}
>>
>> func main() {
>> var population []implementation
>> MyPhase := MakeIntDataPhase()
>> fmt.Println(MyPhase.run(population))
>> }
>>
>>
>> When running following code in playground I got following error: 
>> prog.go:30:25: cannot use population (type []implementation) as type []data 
>> in argument to MyPhase.run
>>
>> If I understand correctly it is because slice of interface type cannot be 
>> converted by the compiler to concrete type.
>>
>>
>> What is correct way in golang to implement functionality that is presented 
>> in the example?
>>
>> When method argument defined using a slice of some interface, how I can pass 
>> it a slice of a concrete type that implements the interface?
>>
>>
> You would end up needing to just do
>
> func (p *phase) run(population {}interface) []data
>
> and then type assert the {}interface into []implementation
> There isn't a way to directly pass a slice of concrete type to a function
> that accepts a slice of interface, unless you first do this:
>
> iface := make([]data, len(population))
> for i, p := range population {
> iface[i] = p
> }
> MyPhase.run(iface)
>
> Justin
>
>>
>> --
>> 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.
>>
>
> --
> 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.
>
>
>

-- 
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] Correct way to solve slice of interface type problem

2018-10-30 Thread robert engels
I have argued for a runtime/built-in to do this - it is so common…. (if doing 
“kind of OO” in Go)

> On Oct 30, 2018, at 7:30 PM, Justin Israel  wrote:
> 
> 
> 
> On Wed, Oct 31, 2018 at 11:21 AM  > wrote:
> Hello, everyone.
> Consider following code:
> 
> package main
> 
> import "fmt"
> 
> type implementation struct {
> d []int
> }
> 
> func (impl *implementation) getData() interface{} {
> return impl.d
> }
> 
> type phase struct{}
> 
> type data interface {
> getData() interface{}
> }
> 
> func MakeIntDataPhase() *phase {
> return {}
> }
> 
> func (p *phase) run(population []data) []data {
> return nil
> }
> 
> func main() {
> var population []implementation
> MyPhase := MakeIntDataPhase()
> fmt.Println(MyPhase.run(population))
> 
> }
> 
> When running following code in playground I got following error: 
> prog.go:30:25: cannot use population (type []implementation) as type []data 
> in argument to MyPhase.run
> If I understand correctly it is because slice of interface type cannot be 
> converted by the compiler to concrete type.
> 
> What is correct way in golang to implement functionality that is presented in 
> the example?
> When method argument defined using a slice of some interface, how I can pass 
> it a slice of a concrete type that implements the interface?
> 
> You would end up needing to just do   
> 
> func (p *phase) run(population {}interface) []data
> 
> and then type assert the {}interface into []implementation
> There isn't a way to directly pass a slice of concrete type to a function 
> that accepts a slice of interface, unless you first do this:
> 
> iface := make([]data, len(population))
> for i, p := range population {
> iface[i] = p
> }
> MyPhase.run(iface)
> 
> Justin
> 
> -- 
> 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 
> .
> 
> -- 
> 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 
> .

-- 
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] Correct way to solve slice of interface type problem

2018-10-30 Thread Justin Israel
On Wed, Oct 31, 2018 at 11:21 AM  wrote:

> Hello, everyone.
> Consider following code:
>
> package main
> import "fmt"
>
> type implementation struct {
> d []int}
>
> func (impl *implementation) getData() interface{} {
> return impl.d}
>
> type phase struct{}
>
> type data interface {
> getData() interface{}}
>
> func MakeIntDataPhase() *phase {
> return {}}
>
> func (p *phase) run(population []data) []data {
> return nil}
>
> func main() {
> var population []implementation
> MyPhase := MakeIntDataPhase()
> fmt.Println(MyPhase.run(population))
> }
>
>
> When running following code in playground I got following error: 
> prog.go:30:25: cannot use population (type []implementation) as type []data 
> in argument to MyPhase.run
>
> If I understand correctly it is because slice of interface type cannot be 
> converted by the compiler to concrete type.
>
>
> What is correct way in golang to implement functionality that is presented in 
> the example?
>
> When method argument defined using a slice of some interface, how I can pass 
> it a slice of a concrete type that implements the interface?
>
>
You would end up needing to just do

func (p *phase) run(population {}interface) []data

and then type assert the {}interface into []implementation
There isn't a way to directly pass a slice of concrete type to a function
that accepts a slice of interface, unless you first do this:

iface := make([]data, len(population))
for i, p := range population {
iface[i] = p
}
MyPhase.run(iface)

Justin

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

-- 
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] Correct way to solve slice of interface type problem

2018-10-30 Thread zloikompot
Hello, everyone.
Consider following code:

package main
import "fmt"

type implementation struct {
d []int}

func (impl *implementation) getData() interface{} {
return impl.d}

type phase struct{}

type data interface {
getData() interface{}}

func MakeIntDataPhase() *phase {
return {}}

func (p *phase) run(population []data) []data {
return nil}

func main() {
var population []implementation
MyPhase := MakeIntDataPhase()
fmt.Println(MyPhase.run(population))
}


When running following code in playground I got following error: prog.go:30:25: 
cannot use population (type []implementation) as type []data in argument to 
MyPhase.run

If I understand correctly it is because slice of interface type cannot be 
converted by the compiler to concrete type.


What is correct way in golang to implement functionality that is presented in 
the example?

When method argument defined using a slice of some interface, how I can pass it 
a slice of a concrete type that implements the interface?

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