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.

should specify all the information that is traditionally provided for the published APIs of libraries in other languages.<br />

<strong>The</strong> syntax of an API definition is identical to the syntax of a component definition, except that:<br />

1. An API definition begins with the special reserved word api rather than component . As with components,<br />

the identifiers associated with APIs that are not included in the <strong>Fortress</strong> standard libraries are prefixed with the<br />

reverse of the URL of the development team.<br />

2. An API does not include export declarations. (However, it does include import declarations, which name<br />

the other APIs used in the API definition.)<br />

3. Only declarations (but not definitions!) are included in an API definition except test and property declarations. A<br />

method or field declaration may include the modifier abstract . (Whether a declaration includes the modifier<br />

abstract has a significant effect on its meaning, as discussed below).<br />

For the sake of simplicity, every identifier reference in an API definition must refer either to a declaration in a used<br />

API (i.e., an API named in an import declaration, or the <strong>Fortress</strong> core APIs, which are implicitly imported), or to a<br />

declaration in the API itself. In this way, APIs differ from signatures in most module systems: they are not parametric<br />

in their external dependencies.<br />

Every API has a unique name that consists of a user-provided identifier. As with components, API equivalence is<br />

determined nominally. Every API also includes a vendor name, the name of the fortress it is compiled on, and a<br />

timestamp.<br />

Component and API names exist in separate namespaces. For convenience, a compiler can also produce an API<br />

directly from a project with the same name as the component it is derived from. Such an API includes matching<br />

declarations of the component. All declarations in the component appear in the API.<br />

A component must include, for every API A it exports, matching definitions for all the declarations in A. A matching<br />

definition of a declaration d is a definition d ′ with the same name as d that includes definitions for all declarations<br />

other than the methods or fields declared abstract in d. <strong>The</strong> header and type of d ′ must be the same as the header<br />

and type of d. d ′ may include additional definitions not declared in d.<br />

For example, consider the APIs <strong>Fortress</strong>.IO, <strong>Fortress</strong>.Security, and <strong>Fortress</strong>.Crypto, with declarations similar<br />

to those in their respective Java packages. <strong>The</strong>se APIs are interdependent. For example, both PublicKey in<br />

<strong>Fortress</strong>.Security and SecretKey in <strong>Fortress</strong>.Crypto extend the trait <strong>Fortress</strong>.IO.Serializable and the trait CipherSpi<br />

in <strong>Fortress</strong>.Crypto has methods that return values of type AlgorithmParameters in <strong>Fortress</strong>.Security. So the API<br />

<strong>Fortress</strong>.Crypto must import <strong>Fortress</strong>.IO and <strong>Fortress</strong>.Security as follows:<br />

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

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

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

. . .<br />

end<br />

22.4 Tests in Components and APIs<br />

A component may include definitions of tests, as described in Chapter 19. <strong>The</strong>se definitions are allowed to refer to<br />

both test and non-test code defined in the same component or declared in APIs imported by the component.<br />

An API may also include definitions of tests. <strong>The</strong>se definitions may refer to all declarations in the API as well as in<br />

any APIs it imports. Tests defined in APIs should be thought of as “executable documentation” that partially specifies<br />

the required behavior of the declared entities.<br />

See Section 22.7 for an explanation of how tests defined in components and APIs are executed.<br />

166

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

Saved successfully!

Ooh no, something went wrong!