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

Should import statements be at the beginning of a module? #337

Open
apblack opened this issue Dec 18, 2023 · 1 comment
Open

Should import statements be at the beginning of a module? #337

apblack opened this issue Dec 18, 2023 · 1 comment

Comments

@apblack
Copy link
Contributor

apblack commented Dec 18, 2023

Are import statements allowed anywhere in a module (like other declarations)? Or must they come at the beginning of a module?

I think that import statements must come at the start of the module, after dialect statements, but before any other statements or declarations. This is for readability, and also to make it easier for the compiler or IDE to collect all of the dependencies and perform a topological sort on them.

Right now, minigrace does not require that imports come at the start of the module. However, the spec says: "Modules may begin with one or more import moduleName as nickname statements" and (in the section on Dialects) "A module may begin with a dialect statement dialect "name" ...". These statements could be clearer: in particular, it makes sense to require that dialect, if present, comes first.

@KimBruce
Copy link
Contributor

KimBruce commented Dec 18, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants