New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
all: be consistent about the term "embedded field" #25684
Comments
@mvdan Yes, we probably want to be as consistent as possible. In the early days we used both terms; more recently we have started talking about 'embedded' fields because even though they are embedded they still have a name (the type name) and thus are not anonymous in the strict sense. That said, note that ast.Fields are also used for parameters which indeed may be anonymous. So we want to be a little bit judicious before making unilateral changes throughout. But feel free to send me CLs. |
I'm not sure I understand; could you please give an example of a field that is embedded and anonymous, and an example of a field that is embedded but not anonymous? |
A Field is part of a FieldList. A FieldList is also used for function signatures (FuncType). Function parameters may be indeed anonymous and then Names may (will) be nil. In that case it makes sense to talk about anonymity (anonymous parameter). Fields are either embedded (originally called anonymous) or not. In short, simply replacing "anonymous" with "embedded" everywhere will be confusing, too (there are no embedded parameters). When making those changes, the comments may need to be adjusted. That's all I'm saying. |
Ah, I understand now - thanks for the clarification. Would you prefer a few CLs grouping changes, or one single CL to clarify these? |
Depends on how many and where the fixes are. Use good judgement. |
Change https://golang.org/cl/120556 mentions this issue: |
Note that this issue was meant to track the inconsistencies across the entire repository, not just this occurrence in |
Reopening per @mvdan 's comment. |
The spec very clearly calls fields with no names "embedded fields": https://golang.org/ref/spec#Struct_types
However, the Go standard library and documentation mixes that term with "anonymous field":
In particular, I found it in https://golang.org/pkg/go/ast/#Field:
Since the spec only mentions one, and it seems to dominate in usage anyway, I think we should try to be as consistent as possible. Specific cases have been fixed in the past, like b396d11.
Of course, this doesn't include names that would break Go1 if changed - it is mainly meant for godocs, comments, and errors messages given by
go/*
andcmd/*
. I presume that old changelogs, such asdoc/devel/weekly.html
, don't need to be changed./cc @griesemer @rsc @mdempsky
The text was updated successfully, but these errors were encountered: