proposal: Go 2: syntax for declaring nested structs #25848
Labels
FrozenDueToAge
LanguageChange
Suggested changes to the Go language
Proposal
v2
An incompatible library change
Milestone
One of the frustrating points for newcomers to Go is the syntax for declaring nested structs. Especially considering other languages make it concise and easily memorable.
Right now that syntax for declaring it in one go looks like this:
And I've noticed a few times that intuitively, people tend to keep the struct A declaration nested, and try to guess the syntax for declaring one instance of it.
That syntax is the following, and it's pretty complicated (again I'm comparing to other scripting languages that provide no type safety at all, it's a pretty unfair comparison):
Which leads to my syntax proposal for doing the same thing:
What is your opinion about this syntax ?
I'm not familiar with the go codebase yet, but I'd be happy to start looking into it, I just wish to see how the go community would receive such a change first.
Also, are there strong reasons (that I don't see) to not introduce that change ?
The text was updated successfully, but these errors were encountered: