19.11.2014 Views

The Fortress Language Specification - CiteSeerX

The Fortress Language Specification - CiteSeerX

The Fortress Language Specification - CiteSeerX

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Fortress</strong>.IO<br />

<strong>Fortress</strong>.Crypto<br />

IronIO<br />

IronCrypto<br />

<strong>Fortress</strong>.IO<br />

<strong>Fortress</strong>.Security<br />

Figure 22.1: Simple components in box notation: A component is represented by a box, with the name of the component<br />

at the top of the box. <strong>The</strong> arrow protruding from the upper right corner of a box is labeled with the APIs exported<br />

by the component. <strong>The</strong> arrow pointing into the bottom of a box is labeled with APIs imported by the component. If<br />

no APIs are imported, we elide the arrow.<br />

Compile This operation takes the source code for a simple component (or API) definition and produces a new<br />

component object (or API object) that is installed on the fortress. Its type is as follows:<br />

compile(file:String):()<br />

For example, suppose IronCrypto.fss contains the source code for the aforementioned IronCrypto application,<br />

which imports <strong>Fortress</strong>.IO and <strong>Fortress</strong>.Security, and exports <strong>Fortress</strong>.Crypto. Suppose we also have source code,<br />

IronIO.fss, for another application, IronIO, which imports nothing and exports <strong>Fortress</strong>.IO. We generate these<br />

components by compiling the source files:<br />

compile("IronIO.fss")<br />

compile("IronCrypto.fss")<br />

<strong>The</strong> results are depicted diagrammatically in Figure 22.1.<br />

Link A collection of one or more components exporting different APIs may be combined to form a new, compound,<br />

component by calling the link operation, passing the names of the components to link along with the name of the<br />

resulting compound component. Syntactically, a link operation is written as follows: 2<br />

link(result:String, constituents:String...):()<br />

<strong>The</strong> components being linked are called constituents of the resulting component, which exports all the APIs exported<br />

by any of its constituents, and imports the APIs imported by at least one of its constituents but not exported by any of<br />

them.<br />

For example, we can link the IronIO and IronCrypto libraries compiled above:<br />

link(IronLink, IronIO, IronCrypto)<br />

<strong>The</strong> resulting component, illustrated in Figure 22.2, imports <strong>Fortress</strong>.Security and exports <strong>Fortress</strong>.IO and <strong>Fortress</strong>.Crypto.<br />

link does not distinguish between simple and compound components, so we can get arbitrarily nested components.<br />

For example, we can construct an application CoolCryptoApp by compiling another source code, IronSecurity.fss,<br />

for the library IronSecurity that imports <strong>Fortress</strong>.IO and exports <strong>Fortress</strong>.Security, and then linking the result with<br />

IronLink.<br />

2 We present only the basic form of link here. link has additional optional arguments that we discuss in the Section 22.8.<br />

168

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

Saved successfully!

Ooh no, something went wrong!