Re: [go-nuts] Extension for type assertion of interface array

2018-04-26 Thread Alex Efros
Hi! On Sun, Apr 22, 2018 at 09:48:13PM -0700, nsakth...@gmail.com wrote: > this pattern requires a language level change to avoid unwanted array copy [...] > but shouldn't the language provide an extension to already available syntax The language is trying to avoid hiding performance-critical

Re: [go-nuts] Extension for type assertion of interface array

2018-04-22 Thread nsakthi93
Type assertion is not required in the given example (from array of structs to interface), But you need to assert if array of one interface is type casted to array of another interface. I started this thread to know whether this pattern requires a language level change to avoid unwanted array

Re: [go-nuts] Extension for type assertion of interface array

2018-04-19 Thread jake6502
Yes, to use the functions above you will need to copy the slices of landSpaceto slices of the respective interface types. But I you do not need to do any type assertions. Like this: https://play.golang.org/p/eFTUqpImyPc package main import ( "fmt" ) type landSpace struct{} func

Re: [go-nuts] Extension for type assertion of interface array

2018-04-19 Thread ankit . gupta
Though the above is not allowed, you can restructure your code to wrap your struct as array in another struct and have area() paas a index to the underlying struct. Something like this (landSpaceArr wraps landSpace struct) - type landSpace struct{ side int } type landSpaceArr struct

Re: [go-nuts] Extension for type assertion of interface array

2018-04-18 Thread nsakthi93
Usescases that I came across doesn't involve []interface{}. My usecases will be similar to this sample code type landSpace struct { //consider that landSpace implements all functions from both Shape and property interfaces ... } type Shape interface {

Re: [go-nuts] Extension for type assertion of interface array

2018-04-18 Thread Jan Mercl
On Wed, Apr 18, 2018 at 4:22 PM Jan Mercl <0xj...@gmail.com> wrote: > On Wed, Apr 18, 2018 at 4:13 PM wrote: > > When possible, avoid using '[]interface{}' and use just 'interface{}' > instead: https://play.golang.org/p/oPtPoGChkMZ. > > > The link should have been:

Re: [go-nuts] Extension for type assertion of interface array

2018-04-18 Thread Jan Mercl
On Wed, Apr 18, 2018 at 4:13 PM wrote: When possible, avoid using '[]interface{}' and use just 'interface{}' instead: https://play.golang.org/p/oPtPoGChkMZ. -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

[go-nuts] Extension for type assertion of interface array

2018-04-18 Thread nsakthi93
Go supports below type assertion t := i.(T) and t, ok := i.(T) Can this feature be extended to array of interfaces as mentioned below? t := i.([]T) and t, ok := i.([]T) I have been using Golang for almost four years and I have come across use cases