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.

α, β type variables<br />

f<br />

method name<br />

x<br />

field name<br />

T<br />

trait name<br />

O<br />

object name<br />

τ, τ ′ , τ ′′ ::= α type<br />

| σ<br />

σ ::= N type that is not a type variable<br />

| O −→ τ <br />

N, M, L ::= T −→ τ type that can be a type bound<br />

| Object<br />

e ::= x expression<br />

| self<br />

| O −→ τ ( −→ e )<br />

| e.x<br />

| e.f −→ τ ( −→ e )<br />

fd ::= f −−−−−−−−−→ αextends N( −→ x:τ):τ = e<br />

method definition<br />

td ::= trait T −−−−−−−−−→ αextends Nextends { −→ N } −→ fd end trait definition<br />

od ::= object O −−−−−−−−−→ αextends N( −→ x:τ)extends { −→ N } −→ fd end object definition<br />

d ::= td definition<br />

| od<br />

p ::= −→ d e program<br />

Figure A.1: Syntax of Basic Core <strong>Fortress</strong><br />

<strong>Fortress</strong> dynamic semantics consists of two evaluations rules: one for field access and another for method invocation.<br />

For simplicity, we use ‘ ’ to denote some parts of the syntax that do not have key roles in a rule. We assume that<br />

does not expand across definition boundaries unless the entire definition is included in it.<br />

A.1.3<br />

Static Semantics<br />

A static semantics for Basic Core <strong>Fortress</strong> is provided in Figures A.3, A.4, and A.5. <strong>The</strong> Basic Core <strong>Fortress</strong> static<br />

semantics is based on the static semantics of Featherweight Generic Java (FGJ) [12]. <strong>The</strong> major difference is the<br />

division of classes into traits and objects. Both trait and object definitions include method definitions but only object<br />

definitions include field definitions. With traits, Basic Core <strong>Fortress</strong> supports multiple inheritance. However, due to<br />

the similarity of traits and objects, many of the rules in the Basic Core <strong>Fortress</strong> dynamic and static semantics combine<br />

the two cases. Note that Basic Core <strong>Fortress</strong> allows parametric polymorphism, subtype polymorphism, and overriding<br />

in much the same way that FGJ does.<br />

We proved the type soundness of Basic Core <strong>Fortress</strong> using the standard technique of proving a progress theorem and<br />

a subject reduction theorem.<br />

314

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

Saved successfully!

Ooh no, something went wrong!