On Wed, 19 Sep 2018 22:30:11 -0700 Sathish VJ <sathis...@gmail.com> wrote:
>
> I've been asked this question a few times and I haven't been able to find 
> an answer.  Why does go reverse the order of variable declaration:  "i int" 
> vs "int i"
>
> Is there anything in the language design that requires this or was it based 
> on readability/writability or related to the parsing process or something 
> else?

It is a bit like Pascal except Go authors unfortunately
removed the ":" separating variables from their type. The main
benefit is you can read a declaration from left to right.

    var foo, bar []int // foo and bar are slices of ints

Contrast:

    int (*(*f)())[] // f is ptr to func returning ptr to array of ptr to int
vs
    var f func()*[]*int // f is func returning ptr to slice of ptr to int

Both can be invoked as "f();" and return a ptr to a slice of
ptrs to int.

This is why you need cdecl to make sense of C declarations.

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

Reply via email to