Skip to content

spec: no mention of "factored" import statements #24011

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

Closed
mvdan opened this issue Feb 21, 2018 · 4 comments
Closed

spec: no mention of "factored" import statements #24011

mvdan opened this issue Feb 21, 2018 · 4 comments

Comments

@mvdan
Copy link
Member

mvdan commented Feb 21, 2018

@josharian just mentioned them in #23966 (comment):

The current format appears to accept single and factored forms. goimports has moved to factored forms only.

I have no idea what it means. The only somewhat-official link I could find via google is https://tour.golang.org/basics/2:

This code groups the imports into a parenthesized, "factored" import statement.

I can understand if the term "factored" doesn't belong in a formal spec. However, if that is a name that people tend to use for it - and given how the Go spec tries to be helpful with examples and notes for newcomers - I think it would be a good addition.

On the other hand, if this term should be avoided, it should be removed from the tour. In that case, I'd be curious to know how to call them. I assume "grouped imports" isn't an option, as that refers to imports within parentheses that have no empty lines in between them.

/cc @griesemer

@rsc
Copy link
Contributor

rsc commented Feb 21, 2018

It's an import block.

@mvdan
Copy link
Member Author

mvdan commented Feb 21, 2018

That sounds more familiar to me, thanks - forgot to mention it in the issue. The spec doesn't explicitly mention it either, though.

Should the tour page be updated to mention import blocks instead?

@griesemer
Copy link
Contributor

I think the tour is pretty clear: First of all the term factored is in double quotes in the tour, making it clear that it's not really a formal term, but it also explains what it is: The import keyword is factored out from a sequence of import declarations, and moved in front of the grouped import declaration. It's the same pattern in elementary algebra: Instead of writing a*b + a*c, one can factor out the a, leading to a*(b + c). Thus for imports: Instead of import "b"; import "c"; one writes import ( "b"; "c" ); - the factored form.

In any case, this is not an issue with the spec. If @josharian likes to use the term but doesn't define it enough, perhaps you should take it up with him? Closing.

@josharian
Copy link
Contributor

Sorry to have caused confusion. I was on my phone and used the first word that sprang to mind to describe them.

@golang golang locked and limited conversation to collaborators Feb 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants