[previous] [up] [next]     [contents] [index]
Next: Examples Up: Core Units Previous: Examples

Linking Units and Creating Compound Units

The compound-unit form links several units into one new compound unit. In the process, it matches imported variables in each sub-unit either with exported variables of other sub-units or with its own imported variables:

  (compound-unit
     (import variable  tex2html_wrap_inline12550 )
     (link [tag (sub-unit-expr linkage  tex2html_wrap_inline12550 )]  tex2html_wrap_inline12550 )
     (export (tag exportage  tex2html_wrap_inline12550 )  tex2html_wrap_inline12550 ))

linkage is one of: variable (tag variable) (tag variable tex2html_wrap_inline12550 )

exportage is one of: variable (internal-variable external-variable)

tag is: identifier

The three parts of a compound-unit expression have the following roles:

The evaluation of a compound-unit expression starts with the evaluation of the link clause's unit expressions (in sequence). For each sub-unit, the number of variables it imports must match the number of linkage specifications that are provided, and each linkage specification is matched to an imported variable by position. Each sub-unit must also export those variables that are specified by the link and export clauses. If, for any sub-unit, the number of imported variables does not agree with the number of linkages provided the exn:unit:arity exception is raised. If an expected exported variable is missing from a sub-unit for linking to another sub-unit, the exn:unit:import exception is raised. If an expected export variable is missing for re-export, the exn:unit:export exception is raised.

The invocation of a compound unit proceeds in two phases to invoke the sub-units. In the first phase, the compound unit resolves the imported variables of sub-units with the bindings provided for the compound unit's imports and new bindings created for sub-unit exports. In the second phase, the internal definitions and expressions of the sub-units are evaluated sequentially according to the order of the sub-units in the link clause. The result of invoking a compound unit is the result from the invocation of the last sub-unit.


[previous] [up] [next]     [contents] [index]
Next: Examples Up: Core Units Previous: Examples

PLT