>
> [][]int{[]int{130,84}, []int{15,46}, []int{44,50}}
>
>
> This seems like an awfully large amount of stuttering to me.
Yes it is, and we spent some time talking about these inner type
specifiers. The problem is that if you take them out, in general the
parsing and execution of initializers like these gets pretty messy, so
we decided to require them with the understanding that they could
potentially be removed if the the syntax got sweeter.
> Is there a simpler way to represent my data?
>
> Ideally I wish I could just go {{130,84},{15,46},{44,50}}
Yes, but what type is that object? It's clear to you, but is it clear
to the compiler? In general it could initialize a lot of different
types.
-rob
what about [][]int{{130,84},{15,46},{44,50}}
This is close to the equivalent Java new int[][]{{130,84},{15,46},
{44,50}}
That helps but what are the types of the inner pieces? You need to
dig into the structure and derive types internally. It's certainly
possible to do this but it's harder than it looks (I speak from
experience) to get it right in all cases. It's also harder than it
looks to define just what is and what is not legal in initializers if
you go this way.
There's no question Go takes the simple route, but I explained why in
my previous message.
-rob
That helps but what are the types of the inner pieces?
On 24/12/2009, at 4:55 PM, eadfrith wrote:
Ideally I wish I could just go {{130,84},{15,46},{44,50}}
Yes, but what type is that object? It's clear to you, but is it clear
to the compiler? In general it could initialize a lot of different
types.
what about [][]int{{130,84},{15,46},{44,50}}
This is close to the equivalent Java new int[][]{{130,84},{15,46},
{44,50}}
You need to dig into the structure and derive types internally. It's certainly possible to do this but it's harder than it looks (I speak from experience) to get it right in all cases. It's also harder than it looks to define just what is and what is not legal in initializers if you go this way.
There's no question Go takes the simple route, but I explained why in my previous message.