Stream: compiler development

Topic: zig compiler - non-global modules


view this post on Zulip Richard Feldman (Feb 22 2025 at 03:14):

I don't think this is written down anywhere, so I wanted to write it down here!

view this post on Zulip Richard Feldman (Feb 22 2025 at 03:16):

I think we've talked in other threads about how:

view this post on Zulip Richard Feldman (Feb 22 2025 at 03:16):

however, this is not completely true

view this post on Zulip Richard Feldman (Feb 22 2025 at 03:16):

really, type-checking our module is only blocked on the other module until we have annotations for its exposed types

view this post on Zulip Richard Feldman (Feb 22 2025 at 03:17):

one way we can get those is to wait until the other module is done being type-checked

view this post on Zulip Richard Feldman (Feb 22 2025 at 03:17):

however, it's also true that if the other module happens to have full type annotations (with no _ in them) for every single one of its exposed values, then we don't need to actually type-check that module to be able to annotate its imports - because we can basically just copy/paste the annotations it explicitly wrote down!

view this post on Zulip Richard Feldman (Feb 22 2025 at 03:18):

obviously the other module still needs to be type-checked eventually in order to confirm that its types agree with one another internally, but that type-checking can be done in parallel with type-checking the module that imports them

view this post on Zulip Richard Feldman (Feb 22 2025 at 03:19):

so essentially, any module where every exposed value has a type annotation with no _ in it is a "non-global module" in that it doesn't require global type inference in order to have fully-annotated exposed types

view this post on Zulip Richard Feldman (Feb 22 2025 at 03:20):

this distinction doesn't matter until we're actually doing parallelization, but once we are, I suspect it allows for a good deal more parallelization in practice

view this post on Zulip Richard Feldman (Feb 22 2025 at 03:21):

actually it might have caching implications too, come to think of it :thinking:

view this post on Zulip Richard Feldman (Feb 22 2025 at 03:22):

because if I'm one of these non-global modules, and a module I import changes its types...I need to have my type-checking redone, but nobody who imports me does

view this post on Zulip Richard Feldman (Feb 22 2025 at 03:22):

because my exposed types haven't changed

view this post on Zulip Richard Feldman (Feb 22 2025 at 03:22):

they're still the same annotations as before

view this post on Zulip Richard Feldman (Feb 22 2025 at 03:23):

anyway, this seems like something we should definitely try at some point, because it should be cheap to check, and in large code bases it will probably apply to 100% of modules in practice

view this post on Zulip Sam Mohr (Feb 22 2025 at 03:24):

Especially with the roc format annotate action, all exposed values should be annotated in healthy codebases


Last updated: Jul 06 2025 at 12:14 UTC