19.11.2014 Views

The Fortress Language Specification - CiteSeerX

The Fortress Language Specification - CiteSeerX

The Fortress Language Specification - CiteSeerX

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Appendix C<br />

Components and APIs<br />

As mentioned in Chapter 22, we formally specify key functionality of the <strong>Fortress</strong> component system, and illustrate<br />

how we can reason about the correctness of the system.<br />

Components One important restriction on components is that no API may be both imported and exported by the<br />

same component. Formally, we introduce two functions on components, imp and exp, that return the imported and<br />

exported APIs of the component, respectively. For any component c, imp(c) ∩ exp(c) = ∅. This restriction is required<br />

throughout to ground the semantics of operations on components, as discussed in Section 22.7.<br />

APIs Other than its identity, the only relevant characteristic of an API a is the set of APIs that it uses, denoted by<br />

uses(a). Because an API a might expose types defined in uses(a), we require that a component that exports a also<br />

exports all APIs in uses(a) that it does not import. Formally, the following condition holds on the exported APIs of a<br />

component c:<br />

a ∈ exp(c) ∧ a ′ ∈ uses(a) =⇒ a ′ ∈ imp(c) ∪ exp(c)<br />

Link Given a set C = {c 1 , . . . ,c k } of components, we define a partial function link(C) that returns the component<br />

resulting from c 1 through c k . If c = link(C), then exp(c) = ⋃ c ′ ∈C exp(c′ ) and imp(c) = ⋃ c ′ ∈C imp(c′ ) − exp(c).<br />

<strong>The</strong> function link is partial because we do not allow arbitrary sets of components to be linked. In particular, Two<br />

components cannot be linked if they export the same API. 1 This restriction is made for the sake of simplicity; it allows<br />

programmers to link a set of components without having to specify explicitly which constituent exporting an API A<br />

provides the implementation exported by the linked component, and which constituent connects to the constituents<br />

that import A: only one component exports A, so there is only one choice. Although we lose expressiveness with this<br />

design, the user interface to link is vastly simplified, and it is rare that including multiple components that export a<br />

given API in a set of linked components is even desirable. We discuss how even such rare cases can be supported in<br />

Section 22.8.<br />

For a compound component, in addition to the exported and imported APIs, we want to know what its constituents<br />

are. So we introduce another function cns, which takes a component and returns the set of its constituents. That<br />

is, cns(link(C)) = C . It is an invariant of the system that for any compound component C (i.e., cns(c) ≠ ∅),<br />

any API imported by any of its constituents is either imported by C or exported by one of its constituents (i.e.,<br />

⋃<br />

c ′ ∈cns(c) imp(c′ ) ⊆ imp(c) ∪ ⋃ c ′ ∈cns(c) exp(c′ )). This property is crucial for executing components, as we discuss<br />

below. A simple component (i.e., one produced directly by compilation) has no constituents (i.e., cns(c) = ∅).<br />

1 <strong>The</strong>re is one exception to this rule: the special API Upgradable, which is used during upgrades discussed below.<br />

340

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!