Skip to content

Conversation

Kha
Copy link
Member

@Kha Kha commented Jul 1, 2025

No description provided.

Copy link
Collaborator

@nomeata nomeata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very helpful overview!

Note also that `import all` is more powerful than the basic `import` before the module system as it allows for accessing imported private definitions directly by name, as if they were defined in the current module.
Thus another use case of `import all` is to make declarations available that need to be used in multiple modules but should not leak outside the current library.

`public import all M` behaves like `public import M` followed by `import all M`, i.e. the `all` modifier becomes irrelevant for downstream modules.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this is really helpful (because it looks like the all is made public), or if we should require writing

public import M
import all M

instead, unless this is a common idiom.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if it's common, I have the same gut feeling when seeing presentations and reading the text. It feels like a footgun.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had exactly the same thought after writing the paragraph, let's do it!

[^meta3]: Semantically unrelated to the modifier of the same name in Lean 3.

A `meta` definition may access (and thus invoke) any `meta` or non-`meta` definition of the current module.
For accessing imported definitions, the definition must either have been marked as `meta` when it was declared or the import must be marked as such (`meta import` when the accessing definition is in the private scope and `public meta import` otherwise).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A question I have when reading this is whether meta import is a superset of import or whether it's orthogonal.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not completely sure yet to be honest; it is currently implemented as a superset. But a public meta import would not necessarily have imply public import if the imported declarations are used only in the bodies of public declarations.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would think that my imports for purposes of metaprogramming/code generation should be reasonably distinct from my imports for purposes of generated run-time code, so that I could depend on a heavyweight library for proof automation but distribute an executable that's independent of it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah you are right of course, we need to change that for the executable size goal

@david-christiansen
Copy link
Collaborator

It looks like a GH Action we depended on got deleted. Rebase on main to get a fixed CI.

Kha and others added 3 commits July 2, 2025 11:46
Co-authored-by: David Thrane Christiansen <david@lean-fro.org>
Co-authored-by: Joachim Breitner <mail@joachim-breitner.de>
@Kha Kha force-pushed the module-system branch from f2c117e to c8aa144 Compare July 2, 2025 09:49
@david-christiansen david-christiansen added the HTML available HTML has been generated for this PR label Jul 2, 2025
Copy link
Contributor

github-actions bot commented Jul 4, 2025

Preview for this PR is ready! 🎉 (also as a proofreading version). built with commit 02ea616.

@Kha Kha merged commit 17fefab into main Jul 4, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

HTML available HTML has been generated for this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants