mirror of
https://github.com/anoma/juvix.git
synced 2024-12-15 01:52:11 +03:00
1.1 KiB
1.1 KiB
Module scoping
This document contains some notes on how the implementation of module scoping is supposed to work.
Import statements
What happens when we see:
import Data.Nat
All symbols defined in Data.Nat
become available in the current module
through qualified names. I.e. Data.Nat.zero
.
Open statements
What happens when we see:
open Data.Nat
All symbols defined in Data.Nat
become available in the current module
through unqualified names. I.e. zero
.
using
and hiding
modifiers are handled in the expected way.
Nested modules
What happens when we see:
module Local; ... end;
We need to answer two questions.
- What happens after
module Local;
. InsideLocal
all symbols that were in scope, continue to be in scope. - What happens after
end;
. All symbols defined inLocal
are in scope through qualified names. One can think of this as the same as importingLocal
if it was a top module.