Skip to content

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

@apblack

Description

@apblack

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions