Skip to content
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

legalize circular imports #30974

Closed
Vany opened this issue Mar 21, 2019 · 2 comments
Closed

legalize circular imports #30974

Vany opened this issue Mar 21, 2019 · 2 comments

Comments

@Vany
Copy link

Vany commented Mar 21, 2019

We know that circular dependencies a banned just because of linking process. Compiler must be fast as possible. But if we can show our agreement to be slightly slow here, like

import (
    ...
    name "path/to/our/circular/importer" `compile:"together"`
)

this tag forces compiler always to compile this two packages together in to single .o

Yes, compilation process now will be slowed down, but another side of this coin is dedicated package with interfaces and indirect calling in runtime.

Another look at this is copackages, in fact it is a single package, but have different namespaces.

also we can do a lot more stuff with this import tags.

@ALTree
Copy link
Member

ALTree commented Mar 21, 2019

Thanks for the report.

This was asked several times in the past, including the recent #30247 (for Go2). It has always been rejected. In particular, see: #30247 (comment) and #30247 (comment).

The consensus in the Go team about allowed circular imports not happening, ever, even in Go2, seems to be quite strong, so I'm closing this issue as a dup of #30247.

@ALTree ALTree closed this as completed Mar 21, 2019
@yanlee26
Copy link

yanlee26 commented Mar 21, 2019 via email

@golang golang locked and limited conversation to collaborators Mar 20, 2020
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

4 participants