7.4 Inferred Linking
syntax
(define-unit unit-id (import tagged-sig-spec ...) (export tagged-sig-spec ...) init-depends-decl unit-body-expr-or-defn ...)
Evaluating a reference to a unit-id bound by define-unit produces a unit, just like evaluating an id bound by (define id (unit ...)). In addition, however, unit-id can be used in compound-unit/infer. See unit for information on tagged-sig-spec, init-depends-decl, and unit-body-expr-or-defn.
syntax
(compound-unit/infer (import tagged-infer-link-import ...) (export tagged-infer-link-export ...) (link infer-linkage-decl ...))
tagged-infer-link-import = tagged-sig-id | (link-id : tagged-sig-id) tagged-infer-link-export = (tag id infer-link-export) | infer-link-export infer-link-export = link-id | sig-id infer-linkage-decl =
((link-binding ...) unit-id tagged-link-id ...) | unit-id
The compound-unit/infer form expands to compound-unit by adding sig-ids as needed to the import clause, by replacing sig-ids in the export clause by link-ids, and by completing the declarations of the link clause. This completion is based on static information associated with each unit-id. Links and exports can be inferred when all signatures exported by the linked units are distinct from each other and from all imported signatures, and when all imported signatures are distinct. Two signatures are distinct only if they share no ancestor through extends.
The long form of a link declaration can be used to resolve ambiguity by giving names to some of a unit’s exports and supplying specific bindings for some of a unit’s imports. The long form need not name all of a unit’s exports or supply all of a unit’s imports if the remaining parts can be inferred.
When a unit declares initialization dependencies, compound-unit/infer checks that the link declaration is consistent with those dependencies, and it reports a syntax error if not.
Like compound-unit, the compound-unit/infer form produces a (compound) unit without statically binding information about the result unit’s imports and exports. That is, compound-unit/infer consumes static information, but it does not generate it. Two additional forms, define-compound-unit and define-compound-unit/infer, generate static information (where the former does not consume static information).
Changed in version 6.1.1.8 of package base: Added static checking of the link clause with respect to declared initialization dependencies.
syntax
(define-compound-unit id (import link-binding ...) (export tagged-link-id ...) (link linkage-decl ...))
syntax
(define-compound-unit/infer id (import link-binding ...) (export tagged-infer-link-export ...) (link infer-linkage-decl ...))
syntax
(define-unit-binding unit-id unit-expr (import tagged-sig-spec ...+) (export tagged-sig-spec ...+) init-depends-decl)
syntax
(invoke-unit/infer unit-spec)
unit-spec = unit-id | (link link-unit-id ...)
When assembling imports from the current context, the lexical information of a unit-id is used for constructing the lexical information of the signatures for the unit’s imports (i.e., the lexical information that would normally be derived from the signature reference). See define-signature for more information.
syntax
(define-values/invoke-unit/infer maybe-exports unit-spec)
maybe-exports =
| (export tagged-sig-spec ...) unit-spec = unit-id | (link link-unit-id ...)
Similar to invoke-unit/infer, the lexical information of a unit-id is used for constructing the lexical information of the signatures for the unit’s inferred imports and inferred exports (i.e., the lexical information that would normally be derived from a signature reference). See define-signature for more information.