Imports and adapter libraries#
The import mechanism: how DS files reference declarations from other DS
files (adapter libraries, rule packs, stdlib), how names
resolve, and what the import-graph contract is. The
compiler-side discovery model — which files the compiler
reads when import X appears in source — is named here as
a build-pipeline concern that the spec does not commit to a
specific shape for.
Paired with:
[LGRA] —
importandfromare class-1 hard keywords; grammar productions live here.[LLEX.10.4] — leading-underscore identifiers.
[LADP] — adapters ship their service declarations as
.dslibrary files consumed viaimport.[LHYD] — hydration services are declared in adapter
.dsfiles.[LCYC] — the cycle-detection pass extends to the import graph.
What this is not#
Not a package-manager spec.
Not a version / dependency-management spec. Version selection is a build-pipeline concern.
Not the adapter-runtime-registration spec — adapter binaries register callbacks against libds's C API separately from the source-level import; see [LADP].
Not a stdlib catalogue. The set of bundled
.dslibrary files the reference compiler ships with is a runtime / distribution concern.
What import does [LIMP.1]#
[LIMP.1.1] An import brings top-level declarations from
another DS file (the library) into the current file's
resolution scope. After import ha, names declared at the
top level of ha.ds resolve under the qualified form
ha.<name> ([LGRA.2.10.4]). After from ha import light, the
name light resolves bare in the importing file. A library
must be imported for any of its symbols to be referenced.
see also: LGRA.2.10.4
[LIMP.1.2] Every import references the library by a
dotted path of identifiers ([LIMP.2.1.1]). The compiler maps that
path to a .ds file via build-pipeline-supplied
discovery. The mapping mechanism does not appear in source.
see also: LIMP.2.1.1
[LIMP.1.3] Library files are DS source files. They use the
same grammar as rule files. A use directive separates the two
([LDIA.2.10.1]), and a program imports libraries only ([LDIA.2.10.7]):
a library file declares schemas, services, consts, and
(rule-pack case) rules meant to be consumed by other files;
a rule file is the consumer.
see also: LDIA.2.10.1, LDIA.2.10.7
[LIMP.1.4] An adapter ships its service declarations as a
library file. Rule authors import the library to call the
adapter's services. The integrator's adapter binary
separately registers callbacks against libds's C API per
[LADP]; the source-level
import and the runtime callback registration connect by
service name.
[LIMP.1.5] A file's declarations resolve in that file's scope. The compiler must resolve every name a file's declarations use, a slot's type and a unit literal in a constant's value among them, against what that file declares, what its own imports bind ([LIMP.1.1]), and what is in scope in every file ([LIMP.12.1], [LUNI.4.1.2]). An importer's declarations, imports and aliases take no part, and neither does a library's own import for its importer, unless the library re-exports the name ([LIMP.4.4.2]).
A file that reads a slot takes the type the declaring file gave it: a schema, a unit, a dimension or an opaque type ([LUNI.4.1.5], [LOPQ.2.3]), whether or not the reading file can name that type itself.
This is names alone. A library is validated under the importing program's settings ([LDIA.2.10.9]).
ratified — see also: LDIA.2.10.9, LIMP.1.1, LIMP.12.1, LIMP.4.4.2, LOPQ.2.3, LUNI.4.1.2, LUNI.4.1.5
Syntax [LIMP.2]#
The two forms [LIMP.2.1]#
[LIMP.2.1.1] DS supports two import forms, each with an optional dotted path:
import_decl ::= 'import' NAME ('.' NAME)* ('as' NAME)? # qualified, optional alias
| 'from' NAME ('.' NAME)* 'import' import_list
import_list ::= import_item (',' import_item)* ','?
| '(' import_item (',' import_item)* ','? ')'
import_item ::= NAME ('as' NAME)? # optional per-name alias
The trailing comma is optional in both import_list alternatives
([LIMP.2.2.2]); the parenthesised one additionally spans lines
([LIMP.2.2]).
see also: LIMP.2.2, LIMP.2.2.2
[LIMP.2.1.2] import ha binds the identifier ha to the
library at ha.ds. Names declared in ha.ds are reachable
as ha.<name> in the importing file ([LGRA.2.10.4], [LGRA.22.9]).
see also: LGRA.2.10.4, LGRA.22.9
[LIMP.2.1.3] from ha import light, switch binds light
and switch directly in the importing file's scope. They
must exist as top-level names in ha.ds. Subsequent
references write light and switch without the prefix.
[LIMP.2.1.4] Dotted paths. A dotted library path
(units.si, adapters.aws.s3) selects a hierarchical
library. The library path in source uses the full dotted form,
and one more . joins it to a member: import units.si reaches
the SI library's meter as units.si.meter ([LGRA.22.9]). The
selective form's body remains a flat list of bare names:
from units.si import meter, kilogram.
ratified — see also: LGRA.22.9
[LIMP.2.1.5] Each segment of a dotted path is an
independently-valid NAME. The first segment must
exist as a top-level library in the search path; subsequent
segments narrow the path through directory levels. The
final segment names a .ds file. No source-level segment
may be a Python-style __init__-equivalent — every dotted
import resolves to exactly one .ds file (LIMP.3.1).
see also: LIMP.3.1
[LIMP.2.1.6] No namespace packages. import units is a
compile error if units.ds does not exist, even when
units/si.ds does. There is no implicit "library is the
directory" rule. Pure grouping prefixes are expressible by
authoring an empty (or re-export-only) units.ds if the
author actually needs import units to mean something; the
common case is to import the specific leaf library directly.
ratified
[LIMP.2.1.7] as aliasing. Either form may rename an imported name with
as (import units.si as u, from b import Sensor as BSensor), but not a
unit declaration: the compiler must refuse as on a selective import of a unit
symbol, a dimension, a scalar group or a formula, with
DS_VALIDATE_UNIT_IMPORT_ALIAS, since such an import brings the library's unit
declarations under their own names ([LIMP.5.1.5]). The compiler
must reject a program that brings two distinct schemas into scope under one
name ([LNAM.2.3.1]) without an alias, with DS_VALIDATE_IMPORT_NAME_COLLISION
([LGRA.22.5]). The check is by schema-object identity — a re-export of the
same schema via two paths is not a collision. A rule names a schema by a
bare NAME in local scope (locally declared, or from lib import Schema) or by a
lib.Schema reference to a schema in an imported library ([LGRA.22.4]); an alias
stands for the library's path there (u.meter). Referencing a schema from a library requires that
library imported; a locally-declared schema needs no import. What an alias leaves
unchanged past the source is [LIMP.13.2]'s.
ratified — see also: LGRA.22.4, LGRA.22.5, LIMP.13.2, LIMP.5.1.5, LNAM.2.3.1
Multi-line parenthesised selective form [LIMP.2.2]#
[LIMP.2.2.1] Long selective-import lists may use a parenthesised multi-line form per LLEX.17.3 (bracket- balanced line continuation).
ratified — see also: LLEX.17.3
[LIMP.2.2.2] A trailing comma after the last name is permitted in
BOTH selective forms — parenthesised or flat. from ha import a,
and from ha import (a,) are equally legal.
Authors use the multi-line form when the comma list exceeds reasonable single-line width; the spec does not specify a column threshold.
The flat form admits the trailing comma as the parenthesised one does
([LIMP.2.1.1]'s import_list): the two forms differ only in line breaks, and a
rule that changed with them would be a trap.
ratified — see also: LIMP.2.1.1
Placement [LIMP.2.3]#
[LIMP.2.3.1] Imports cluster at the top of a DS file. They
appear after the use <dialect> directive (per LGRA.3.1)
and before any other top-level declaration.
see also: LGRA.3.1
[LIMP.2.3.2] An import or from ... import after a
non-import top-level declaration (schema, service, const,
rule) is a compile error. Lazy imports are disallowed in
v1; the file's import set is fully visible at the top.
ratified
[LIMP.2.3.3] An import before a use <dialect> directive
is a compile error. use is the file's first directive
when present; imports follow.
ratified
What the import surface does not admit [LIMP.2.4]#
[LIMP.2.4.2] * wildcard. from ha import * is a
parse error (DS_PARSE_GENERIC). The selective-import list must enumerate
each imported name.
ratified
[LIMP.2.4.3] There is no restriction on module-path depth. Dotted module
paths (import a.b.c) are admitted per [LIMP.2.1.4]; see [LIMP.3.1.4] for
the discovery convention.
ratified — see also: LIMP.2.1.4, LIMP.3.1.4
[LIMP.2.4.4] Conditional / dynamic imports. Imports appear only at file top-level.
Resolution and discovery [LIMP.3]#
Library-name to file [LIMP.3.1]#
[LIMP.3.1.1] When the compiler encounters import ha, it
resolves the identifier ha to a single .ds file via a
build-pipeline-supplied search path or explicit file list.
The mechanism is a compiler invocation concern; the spec
does not commit to a fixed environment variable or
filesystem layout, except for the place of the library the compiler ships with
([LIMP.3.3.1]).
see also: LIMP.3.3.1
[LIMP.3.1.2] If no .ds file resolves for the requested
identifier, the compiler emits DS_VALIDATE_UNKNOWN_LIBRARY
naming the identifier and (when available) the search path
the compiler attempted.
[LIMP.3.1.3] If multiple .ds files resolve for the same
identifier, the compiler emits
DS_VALIDATE_AMBIGUOUS_LIBRARY listing the candidates.
Authors and build-pipeline operators eliminate the
ambiguity at the build-pipeline level.
[LIMP.3.1.4] Dotted-path resolution. A dotted import
import a.b.c resolves by walking the segments as
directory names against the search path, with the final
segment matched as the .ds filename. For search path
entry <root>, the candidate file is <root>/a/b/c.ds.
The resolver checks each search-path entry in order; the
first match wins. Intermediate directories that do not
exist on a given root simply mean no match at that root —
the resolver continues to the next entry.
ratified
[LIMP.3.1.5] An importer's request for import a.b does
not match a file at <root>/a.b.ds (the dot inside the
filename is treated as a literal dot, not a path separator).
The dotted form is exclusively a path-segment separator at
import resolution time. Filenames with embedded dots are not
valid library identifiers (consistent with [LIMP.7]'s
single-NAME library-name constraint per segment).
see also: LIMP.7
[LIMP.3.1.6] No namespace packages (per LIMP.2.1.6).
A search-path entry that has only a/b.ds but no a.ds
does not admit import a — the latter is a compile error.
Each importable name corresponds to exactly one .ds file
on disk (or one entry in the in-memory loader).
see also: LIMP.2.1.6
[LIMP.3.1.7] A library that resolves but does not parse is reported
against the import. When a search-path entry yields a file for the
requested identifier — [LIMP.3.1.2] having found one — and that file fails
to parse, the compiler must emit DS_VALIDATE_LIBRARY_PARSE_FAILED at the
importing file's import line, naming the library and carrying the
underlying parse failure in the message.
The location is the commitment here, and it is what an alternative implementation could reasonably get differently. An author sees one pointer, at a line in a file they wrote, instead of a position inside a library they may not have written and cannot edit. The underlying failure is not discarded — it travels in the message — but it does not become the diagnostic's primary span, because a span into another file is not somewhere the importing author can act.
This is the one resolution outcome distinct from [LIMP.3.1.2]'s: there, no file answers to the identifier at all; here, one does and is not valid DS.
see also: LIMP.3.1.2
Adapter-installation as the discovery convention [LIMP.3.2]#
[LIMP.3.2.1] An adapter is a deployment unit consisting of
a binary (which links libds and registers callbacks at
engine init) and a .ds library file (which declares the
adapter's services). When the integrator installs an
adapter, both artefacts land in their respective
consumers' paths:
[LIMP.3.2.2] The
.dsfile lands where the compiler finds it via the build pipeline's search-path configuration.
[LIMP.3.2.3] The binary lands where the runtime's integrator-build links to it.
[LIMP.3.2.4] The two artefacts connect at compile time
through service names: the compiler reads service decls
from the .ds and emits manifest atoms into the DSC; at
runtime libds binds the integrator's callbacks to the
service names the DSC declares per
[LADP].
Stdlib bundling [LIMP.3.3]#
[LIMP.3.3.1] The reference compiler ships with a bundled
set of .ds library files: the standard library, units.core ([LUNI.4.1.2])
and the canonical adapters' libraries among them.
These resolve through the same search path as integrator-
installed adapters; the bundle is one entry on the
search path, after every entry the invocation names.
The bundle is always there. It ships as .ds
files, and the compiler must not carry their content compiled in. Every
build of the compiler must find the bundle where [RCLI.1.11] puts it, with
nothing for an author, an integrator or a developer to set up, so one compiler
accepts the same programs wherever it runs.
see also: LUNI.4.1.2, RCLI.1.11
[LIMP.3.3.2] No library is implicitly imported; the built-in module that every compilation imports is not a library ([LIMP.12.1]). A rule file imports each adapter library whose services it calls, and imports none it does not use.
see also: LIMP.12.1
[LIMP.3.3.4] math, distance and calendar carry builtins. The standard
library's modules math, distance and calendar each carry, besides what their source declares,
the builtin functions [LEXP.17.2] lists under their name; no other library
carries a builtin, and no author module can declare one. math's source
declares three Float constants, each the binary64 nearest its value:
Constant |
Value |
Literal |
|---|---|---|
|
π |
|
|
e |
|
|
2π |
|
distance and calendar declare nothing in source. A program reaches a member
of any of the three only through an import of it ([LIMP.3.3.2]): qualified,
math.sin after import math, or bare, sin after from math import sin
([LGRA.22.9]). A member's name is not a reserved word
([LLEX.9.6]), and the compiler must reject a use of it that no import reaches as
[LGRA.22.7] rejects an unresolved NAME: a call of one is
DS_VALIDATE_UNKNOWN_FUNCTION.
ratified — see also: LEXP.17.2, LGRA.22.7, LGRA.22.9, LIMP.3.3.2, LLEX.9.6
[LIMP.3.3.3] The cache plane verbs (cache,
cache_delete, cached(...)) are language primitives
declared in [LGRA.10], not
services declared in a stdlib library. They do not require
an import.
ratified — see also: LGRA.10
Namespace and visibility [LIMP.4]#
Qualified names from import NAME [LIMP.4.1]#
[LIMP.4.1.1] After import ha, every top-level
declaration in ha.ds whose name does not begin with _
is reachable as ha.<name> in the importing file ([LGRA.2.10.4]).
This covers schema, const, and rule declarations
alike; the resolution rule is uniform across them. A
service is not reached through a library: services live in
one global namespace ([LGRA.10.1.6]).
ratified — see also: LGRA.10.1.6, LGRA.2.10.4
[LIMP.4.1.2] A qualified reference joins the library to the
symbol with . at every use site: ha.AlarmTriggered. Bare
AlarmTriggered written without from ha import AlarmTriggered does not resolve; ha.AlarmTriggered
requires import ha. A library is imported to be referenced
either way. In a type position the compiler must refuse a
qualified reference whose library the file does not import with
DS_VALIDATE_UNKNOWN_QUALIFIER. In expression position such a name
is unresolved ([LGRA.22.9]).
ratified — see also: LGRA.22.9
Bare names from from NAME import ... [LIMP.4.2]#
[LIMP.4.2.1] After from ha import AlarmTriggered, MAX_TEMP,
the names AlarmTriggered and MAX_TEMP resolve bare in the
importing file. They refer to the same declarations
reachable via ha.AlarmTriggered and ha.MAX_TEMP.
[LIMP.4.2.2] The selective-import list enumerates names
the importer wants in bare scope. Names not enumerated do
not enter bare scope but remain reachable via the qualified
form when the library is also imported via
import NAME.
[LIMP.4.2.3] An importer that uses both forms — import ha
followed by from ha import AlarmTriggered — has both
ha.AlarmTriggered and AlarmTriggered in scope; both
resolve to the same declaration.
This is permitted (no double-import error) so authors can
use the qualified form for some names and the bare form
for others from the same library.
[LIMP.4.2.4] Each name in the selective-import list is a
single identifier. Dotted forms (from ha import light.turn_on) are compile errors. The importable
identifiers are the principal names declared at the
library's top level — schemas, consts, rules, flat-named
services, and domains. A domain is the first-segment
identifier of any dotted-name service declaration in the
library; importing the domain brings the whole <domain>.*
service set into bare scope.
ratified
[LIMP.4.2.6] A service's own name stays dotted, and a call
names it bare. call light.turn_on resolves whatever form
imported the declaring library, import ha and
from ha import light alike; no library qualifier applies to
a service ([LGRA.10.1.6]).
see also: LGRA.10.1.6
Leading-underscore-internal convention [LIMP.4.3]#
[LIMP.4.3.1] Identifiers in a library file that begin with a single underscore are internal to that library. They are reachable inside the library file itself but do not participate in import resolution.
[LIMP.4.3.2] Underscore-prefixed identifiers do not enter the
import-resolution lookup tables, so external references fall
through to the same diagnostics that fire for any unknown
imported name. from ha import _helper rejects with
DS_VALIDATE_UNKNOWN_IMPORT_NAME (the name is not in any of
the schema / const / rule / domain / flat-service tables the
selective-import precedence consults). ha._helper in
expression position rejects with
DS_VALIDATE_UNKNOWN_QUALIFIED_CONST; ha._Helper in
pattern position rejects with DS_VALIDATE_UNKNOWN_SCHEMA.
The "internal" status is enforced structurally — by absence
from the lookup — rather than through a distinct error code.
ratified
[LIMP.4.3.3] Library authors use the leading-underscore convention for helper schemas, helper consts, helper rules that the library uses internally but does not commit to as public contract. The convention is enforced at the import-resolution layer.
[LIMP.4.3.4] The NAME terminal ([LLEX.10]) admits a leading single
underscore. Its character set is [LNAM.2.2.1]'s — XID_Start /
XID_Continue narrowed by UAX #39 — not ASCII.
see also: LLEX.10, LNAM.2.2.1
Re-export through selective import [LIMP.4.4]#
[LIMP.4.4.1] When library A's source contains
from B import X, the name X becomes part of A's
top-level decl set. An importer of A subsequently sees X
through import A (as A.X) or through
from A import X (bare).
ratified
[LIMP.4.4.2] Library A's bare import B does not propagate
B's names through A. import B inside A makes B reachable
inside A's source only; importers of A do not see B's names
unless A explicitly re-exports through from B import ....
ratified
[LIMP.4.4.3] This gives library authors deliberate control over their public contract. Internal use of B stays private; selectively re-exported names from B become part of A's contract.
Conflict resolution [LIMP.5]#
[LIMP.5.1.5] A unit name is bound once. Import order never chooses between two units: a unit literal means one declaration, whatever order the imports are written in. The compiler must refuse, at the second binding:
a unit that the file imports by name from two different libraries, with
DS_VALIDATE_UNIT_IMPORT_COLLISION, even where both declare the same conversion;a local
unitdeclaration whose name the file imports, withDS_VALIDATE_UNIT_LOCAL_SHADOWS_IMPORT;a local
unitdeclaration that names a base unit or alias ofunits.core([LUNI.4.1.2]), withDS_VALIDATE_UNIT_IMPORT_COLLISION.
The author imports the unit from one library, or renames the local declaration.
ratified — see also: LUNI.4.1.2
Duplicate import and selective-list duplicates [LIMP.5.2]#
[LIMP.5.2.2] A duplicate name in a selective-import list
(from ha import light, light) is accepted silently with a
single binding. Style guides discourage the form; the
compiler does not reject it.
ratified
[LIMP.5.2.3] The compiler must accept a file that imports one library more
than once under one qualifier (import ha written twice), with a single binding
of the qualifier.
ratified
[LIMP.5.2.4] A qualifier names one library. The compiler must refuse a file
that binds one qualifier to two different libraries (import a as q with
import b as q, or import a as b with import b), at the second import, with
DS_VALIDATE_IMPORT_NAME_COLLISION.
Service-path conflicts across libraries [LIMP.5.3]#
[LIMP.5.3.1] A service is identified by its name alone, not by the library that declares it. Two libraries in one compilation that declare a service of the same name collide, and the compiler refuses the program ([LCRS.14.9]).
ratified — see also: LCRS.14.9
Import-graph cycles [LIMP.6]#
[LIMP.6.1] The compiler builds an import-graph: nodes are
library files (and the compilation-unit rule file); edges
are import and from ... import statements. Any cycle is
rejected with DS_VALIDATE_IMPORT_CYCLE.
ratified
[LIMP.6.2] The cycle check extends the existing rule-graph cycle pass per [LCYC]. Both pin the same underlying invariant: DS source forms a directed acyclic graph at every level.
[LIMP.6.3] Library authors structure their dependencies as a DAG. If two libraries genuinely need to share schemas, a third library hosts the shared schemas; both import the third.
What's importable [LIMP.7]#
[LIMP.7.1] A library file's importable surface is its
top-level declarations whose names do not begin with _:
ratified
[LIMP.7.2]
schemadeclarations.
ratified
[LIMP.7.3]
servicedeclarations (per [LADP]).
ratified
[LIMP.7.4]
constdeclarations.
ratified
[LIMP.7.5]
ruledeclarations.
ratified
[LIMP.7.6] Adapter libraries primarily declare service
and schema; rule packs primarily declare rule and
schema. The import mechanism does not distinguish between
the two — both are DS source files imported through the
same syntax.
[LIMP.7.7] An importer that references a name not declared
at the imported library's top level is rejected with
DS_VALIDATE_UNKNOWN_IMPORT_NAME naming the import line and
the missing identifier. The diagnostic carries a hint listing
the lookup tables the precedence walk consulted (schema /
const / rule / domain / flat-service / unit / unit formula) so
authors can tell whether the name should have been a different
decl kind.
A unit and a unit formula ([LUNI.4.5]) are top-level declarations an
importer may name. A formula is imported by its formula name, which brings
both of its functions; a function name alone is not an importable name.
ratified — see also: LUNI.4.5
Dependency expression and version skew [LIMP.8]#
No source-level version [LIMP.8.1]#
[LIMP.8.1.1] import statements name a library by
identifier and nothing else. The compiler does not accept
version constraints, version pins, or any other dependency
metadata in source.
[LIMP.8.1.2] Version selection is a build-pipeline concern.
Whatever .ds file resolves to the imported identifier is
what the compiler reads. The build pipeline is responsible
for ensuring the resolved file matches the integrator's
deployed adapter binary.
Skew detection [LIMP.8.2]#
[LIMP.8.2.1] Skew between an adapter binary and the .ds
library it ships with surfaces at runtime through name-
match checks. When the integrator registers a callback
against libds for a service name the loaded DSC does not
declare, libds rejects the registration. When the DSC
declares a service for which no callback is registered at
engine-ready, libds rejects the engine-ready transition.
[LIMP.8.2.2] These checks already serve as version-skew detection. The DSC and the adapter binary connect through service names; mismatched service sets surface as registration-time errors, not silent dispatch failures.
Import commitments [LIMP.9]#
[LIMP.9.1] Two import forms only.
import NAMEfor qualified access,from NAME import NAME (',' NAME)*for selective bare access. Multi-line parenthesised selective form per LIMP.2.2.
ratified — see also: LIMP.2.2
[LIMP.9.2] A selective import enumerates each name ([LIMP.2.4.2]):
from NAME import *is a parse error.
ratified — see also: LIMP.2.1.4, LIMP.2.1.7, LIMP.2.4.2
[LIMP.9.3] Imports cluster at file top. After
use <dialect>(when present); before any other declaration. Lazy imports are a compile error. Restates [LIMP.2.3.1].
ratified — see also: LIMP.2.3.1
[LIMP.9.4] Resolution is a build-pipeline concern. The compiler accepts a search path / file list; the spec does not commit to a fixed environment variable or layout, except for the bundled library's place ([LIMP.3.3.1]). Restates [LIMP.3.1.1].
ratified — see also: LIMP.3.1.1, LIMP.3.3.1
[LIMP.9.5] Adapter installation establishes the discovery convention. Adapters ship a
.dslibrary file alongside their binary; both land in their respective consumers' paths.
[LIMP.9.6] Stdlib
.dsfiles ship with the reference compiler distribution. The canonical storage adapter and any other reference-runtime services resolve through the same search path. No library is implicitly imported ([LIMP.3.3.2]).
ratified — see also: LIMP.3.3.2
[LIMP.9.7] Cache verbs are language primitives.
cache,cache_delete,cached(...)do not require an import; they are not service calls. Restates [LIMP.3.3.3].
ratified — see also: LIMP.3.3.3
[LIMP.9.8] Python-style namespace.
import Xkeeps names qualified asX.<name>;from X import a, bbringsaandbbare.import Xinside library A does not propagate B's names to A's importer; explicitfrom B import Xre-exports.
ratified
[LIMP.9.9] Leading underscore is internal. Identifiers beginning with
_in a library file are internal; the import-resolution layer rejects external references to them. TheNAMEterminal per LLEX.10 permits a leading single underscore.
ratified — see also: LLEX.10
[LIMP.9.11] Import cycles are compile errors. The cycle-detection pass per [LCYC] extends to the import graph;
DS_VALIDATE_IMPORT_CYCLEreports the cycle path. Restates [LIMP.6.2].
ratified — see also: LIMP.6.2
[LIMP.9.12] Version selection lives in the build pipeline, not on an
import. Skew between an adapter binary and its.dslibrary surfaces through name-match checks at engine init.
ratified
Import non-commitments [LIMP.10]#
[LIMP.10.5] Search-path environment-variable conventions are not specified. The language commits to no variable name and no layout; each compiler picks its own. Rule sources must not depend on a particular one.
The built-in module [LIMP.12]#
[LIMP.12.1] Every compilation imports the built-in module. The compiler must import it into every source file it compiles, and no program can decline it. The module declares the built-in schemas of [LIMP.12.2] and nothing else: no rule, constant, unit or service.
The built-in module is not a library ([LIMP.3.3.2]). It has no path, so no
import names it and no as alias renames it ([LIMP.2.1.7]), and no dotted name
reaches into it ([LGRA.22.9]). Its schemas are in scope by their bare names in
every file.
ratified — see also: LGRA.22.9, LIMP.12.2, LIMP.2.1.7, LIMP.3.3.2
[LIMP.12.2] The built-in schemas. Each is defined by the clause the table names, and the compiler must declare it exactly as that clause states: its name, its scope and lifetime, and its slots in the clause's order. A schema is written into an artefact when the program uses it: when the condition its row gives holds, or when the program names the schema. A built-in schema the program does not use is left out.
Schema |
Defined by |
Written into the artefact |
|---|---|---|
|
[LERR.9.2] |
always ([LERR.9.4]) |
|
[LERR.9.3] |
always ([LERR.9.4]) |
|
[LCRS.4.2.1] |
when the program contains a |
|
[LHYD.5.1] |
when the program dispatches a hydration call ([LHYD.6.3.1]) |
|
[LHYD.4.3.1] |
when the program dispatches a |
|
[LTIM.10.6] |
always |
CallError is written for every program with a call, whether or not a rule
matches it, because an adapter may assert one for any call ([LCRS.4.2.2],
[LCRS.17.1]). TimeZoneOffset is written for every program, because the
integrator supplies its facts whatever the program reads ([LTIM.10.10]).
A rule that matches CallError in a program with no call is inert, since no
adapter answers a call the program never makes. Its schema is still written,
because the rule names it, and an artefact whose AlphaNode names a schema it
lacks is refused at load ([RDSC.8.7]).
ratified — see also: LCRS.17.1, LCRS.4.2.1, LCRS.4.2.2, LERR.9.2, LERR.9.3, LERR.9.4, LHYD.4.3.1, LHYD.5.1, LHYD.6.3.1, LTIM.10.10, LTIM.10.6, RDSC.8.7
[LIMP.12.3] A built-in schema's name is taken in every file. An author must
not declare a schema under a name [LIMP.12.2] lists, and the compiler must
refuse such a declaration: with DS_VALIDATE_RESERVED_TYPE_NAME for
ComputationError and TypeError, whose names are reserved words
([LERR.9.4]), and with DS_VALIDATE_IMPORT_NAME_COLLISION ([LIMP.2.1.7]) for
the others. No alias resolves the collision, because nothing names the module
([LIMP.12.1]).
A built-in schema is therefore the same in every program. No program declares
its own CallError, so none changes its lifetime ([LCRS.6.6.1]).
ratified — see also: LCRS.6.6.1, LERR.9.4, LIMP.12.1, LIMP.12.2, LIMP.2.1.7
[LIMP.12.4] scope internal belongs to the built-in module alone. The
module may declare a schema scope internal ([LSCP.2.6]), and declares
ComputationError and TypeError so. No other source can: internal is absent
from the author grammar's <scope-value> ([LSCP.1.5], [LSCP.2.6.2]).
The module's declarations are the compiler's own, as [LLEX.9.5] treats a schema the compiler declares.
see also: LLEX.9.5, LSCP.1.5, LSCP.2.6, LSCP.2.6.2
A schema's own name [LIMP.13]#
[LIMP.13.1] Every schema has one own name. The compiler must give each schema the own name its declaration's place decides:
Declared in |
Own name |
|---|---|
the file being compiled |
its |
a library |
the library's dotted import path, a |
the built-in module ([LIMP.12.1]) |
its |
The path is the one [LIMP.3.1.4] resolves. It is never an as alias, a
search-path entry or a file path. A schema reached through a re-export
([LIMP.4.4.1]) has the own name the library that declares it gives it. A
synthetic schema's name is [LLEX.10.6.1]'s.
So no two distinct schemas of a program share an own name: a NAME holds no .
([LIMP.4.3.4]), a path resolves to one file ([LIMP.3.1.3]), and a file declares
a NAME once.
ratified — see also: LIMP.12.1, LIMP.3.1.3, LIMP.3.1.4, LIMP.4.3.4, LIMP.4.4.1, LLEX.10.6.1
[LIMP.13.2] Past the source, a schema's own name is its only name. The
compiler must write it wherever an artefact names a schema ([RDSC.5.2]). A
recording carries it ([RFCS.6.2]), a FactExternal carries it ([RFCS.23.3]), and
a host names a schema by it ([NFCT.1.4.2]). An as alias and a lib.Schema
reference are spellings in one source file, and neither reaches an artefact.
A rule therefore reads, emits and answers one schema, and a slot refers to one ([LIMP.1.5]), whatever a file calls it, and two distinct schemas a file holds under two aliases stay two schemas ([LIMP.2.1.7]).
ratified — see also: LIMP.1.5, LIMP.2.1.7, NFCT.1.4.2, RDSC.5.2, RFCS.23.3, RFCS.6.2
[LIMP.13.3] Two programs share a schema by its own name. A fact crosses
between tiers only where each holds a schema of that own name ([RFCS.23.3]): each
imports one library under one path, or each declares the NAME in the file it
compiles. A Reply one program declares and a lib.Reply another imports are
two schemas, however alike their slots, and the receiver refuses the record.
ratified — see also: RFCS.23.3