This is allowed:
package main
var a = 3
...
But this isn't:
package main
a := 3
...
Why not? Why couldn't short variable declaration outside a function be treated regular declaration without a type? Just to simplify parsing?
This is allowed:
package main
var a = 3
...
But this isn't:
package main
a := 3
...
Why not? Why couldn't short variable declaration outside a function be treated regular declaration without a type? Just to simplify parsing?
According to Ian Lance Taylor in this thread shortly after the public announcement:
At the top level, every declaration begins with a keyword. This simplifies parsing.