The declaration syntax contradicts the commentary.<p>Functions do not read from left to right. The example of<p><pre><code> func main(argc int, argv *[]byte) int
</code></pre>
is explained as "function main takes an int and a pointer to a slice of bytes and returns an int" but it should read "main is a function which takes an int and a pointer to a slice of bytes and returns an int" just like<p><pre><code> x int
</code></pre>
means "x is an integer". Reading left to right the variable name should come first for functions as for other variables so the function syntax should be<p><pre><code> main func(argc int, argv *[]byte) int
</code></pre>
But this can't be so because this appears to be the syntax that function variables use<p><pre><code> f func(func(int,int) int, int) int
</code></pre>
which is explained as "Here's a declaration of a function variable (analogous to a function pointer in C)".<p>Also the article says "Pointers are the exception that proves the rule" because "For familiarity, Go's pointers use the * notation from C, but we could not bring ourselves to make a similar reversal for pointer types.".<p>Putting these two observations together I would say that Go's declaration syntax fails in its stated mission of simplicity and regularity.<p>EDIT: can't seem to work out how to code markup on HN, anyway I hope I've made what I'm trying to say clear enough.<p>UPDATE: two spaces at the start of a line seems to work
As a crazy random thought, wouldn't '@' work well as an alternative to the asterisk to dereference pointers? It's available, it's ASCII, it's pronounced "at" which seems to jive with pointer semantics, and it's not used in C-like languages.<p>Just a very quick thought after reading Mr Pike's closing words that the use of the asterisk for pointers makes the syntax a bit clumsier than they would have wished.
The more I use Go the more I realise how much thought has gone into every language decision and (just as importantly) how much restraint has gone into the design.<p>It's my first tool of choice for everything now.
great explanation and advocacy, and also good to see Pike's name as the author, gives the language a cred boost in my eyes. maybe i'll add it to the same bucket I consider D to be in as a possible successor to C for certain niches.
Could use a better title... it's the golang.org's <i>blog</i>, and it's an explanation <i>of</i> the syntax, which is not really implied by "Go's declaration syntax". With just the domain and title, I'd assumed this was just documentation (as sometimes gets posted on hn), not discussion, and skipped over it several times.<p>All in all interesting, and I definitely agree with the improvement with their "function-returning function which accepts a function as an argument" example. An interesting departure from C & languages influenced by C (ie: most).
You might compare the results with SPECS: <a href="http://en.wikipedia.org/wiki/Significantly_Prettier_and_Easier_C%2B%2B_Syntax" rel="nofollow">http://en.wikipedia.org/wiki/Significantly_Prettier_and_Easi...</a> -- an alternate syntax for C++. I find its productions clearer than those of Go's.