DEV Community

Discussion on: What ever happened to putting the object type on the left?

Collapse
 
migu profile image
Michael Gutbier • Edited

There's a blog article about Go's declaration syntax that explains the reasoning behind it: blog.golang.org/gos-declaration-sy...

The article gives a good example what a mess C code can become if pointers are used. In C, the declaration for the example function looks like this, parameter names omitted. The function returns a function pointer and also expects a function pointer as the first parameter.

int (*(*fp)(int (*)(int, int), int))(int, int)

In Go, the same is much easier to read:

f func(func(int,int) int, int) func(int, int) int

That being said, Go also makes exceptions when needed. Read the article for more information.