-
Notifications
You must be signed in to change notification settings - Fork 4
schema language
This is a draft page filled as we go with the language implementation
#Imports There are three kinds of imports: star imports, namespace imports and single type imports.
Star imports bring all types from a given namespace into the scope, but not from any nested namespaces. For example:
import foo.bar.*
record R {
myField: Baz // can be foo.bar.Baz
}
Single type import makes one single type from another package available:
import foo.bar.Baz
record R {
myField: Baz
}
Importing types with the same short name from different namespaces is not allowed:
import foo.bar.Baz
import qux.Baz // clash!
Namespace import brings given namespace into scope, so that namespace prefix can be omitted:
import foo.bar
record R {
myField: bar.Baz
}
Importing namespaces with the same last segment is not allowed:
import foo.bar
import qux.bar // clash!
Resolution algorithm works by building a set of namespace prefixes to search
plus a suffix to look for. For example if prefixes are p1.p2
and p3.p4
and
suffix is p5.P
then p1.p2.p5.P
and p3.p4.p5.P
fully-qualified names will
be the final candidates.
Internally there are two kinds of imports: star imports and prefix imports. Both namespace and single type imports are treated as prefix imports.
Resolution of reference R
depends on if it's a sequence of fragments
n1.n2...T
or just one fragment T
.
If R
is just a single fragment like Baz
, then namespace prefix set consists
of current file's namespace and all star imports, and suffix is just R
.
// TODO and built-in namespace(s): epigraph.types.* epigraph.schema.*
If R
contains multiple fragments starting with n1
, then prefix set is
a union of all prefix imports such that their last segment is n1
, with last
segment removed. Search suffix is again R
.
// TODO this time built-in namespaces are not included