Re: [go-nuts] Any reason why this type conversion is not allowed?

2020-04-14 Thread Glen Huang
@lan @Shulhan Thanks. Glad to know the design goal much better. On Tuesday, April 14, 2020 at 1:07:36 PM UTC+8, Ian Lance Taylor wrote: > > On Mon, Apr 13, 2020 at 6:56 PM Glen Huang > > wrote: > > > > Given > > > > type Data []byte > > s := [][]byte{{1},{2}} > > > > I wonder why this

Re: [go-nuts] Any reason why this type conversion is not allowed?

2020-04-13 Thread Ian Lance Taylor
On Mon, Apr 13, 2020 at 6:56 PM Glen Huang wrote: > > Given > > type Data []byte > s := [][]byte{{1},{2}} > > I wonder why this conversion isn't allowed? > > []Data(s) > > Seems pretty straightforward. Maybe I miss some edge cases where things won't > square?

Re: [go-nuts] Any reason why this type conversion is not allowed?

2020-04-13 Thread Personal
> On 14 Apr 2020, at 09.46, Glen Huang wrote: > > With all due respect, I think assigning to interface{} is orthogonal to the > question, which deals with variance. (I asked about it here: > https://groups.google.com/forum/#!topic/golang-nuts/S4p54OpQHGw) > > Here, the type is redefined, so

Re: [go-nuts] Any reason why this type conversion is not allowed?

2020-04-13 Thread Glen Huang
With all due respect, I think assigning to interface{} is orthogonal to the question, which deals with variance. (I asked about it here: https://groups.google.com/forum/#!topic/golang-nuts/S4p54OpQHGw) Here, the type is redefined, so in the context of conversion, it and the original should be

Re: [go-nuts] Any reason why this type conversion is not allowed?

2020-04-13 Thread Marcin Romaszewicz
Go doesn't do any implicit type conversions, and it's quite consistent about that. The only things which are type "converted" are untyped constants. I would love for this to work too, by the way, since I often come up with something like: var a []interface{} var b []SomethingConcrete I would

[go-nuts] Any reason why this type conversion is not allowed?

2020-04-13 Thread Glen Huang
Given type Data []byte s := [][]byte{{1},{2}} I wonder why this conversion isn't allowed? []Data(s) Seems pretty straightforward. Maybe I miss some edge cases where things won't square? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To