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.

6.3 Local Variable Declarations<br />

Syntax:<br />

LocalVarDecl ::= LocalVars (=|:= ) Expr<br />

| LocalVarWTypes<br />

| LocalVarWoTypes : TypeRef ... [( = | := ) Expr]<br />

| LocalVarWoTypes : SimpleTupleType [( = | := ) Expr]<br />

LocalVars ::= LocalVar<br />

| ( LocalVar ( , LocalVar) + )<br />

LocalVar ::= LocalVarWType<br />

| LocalVarWoType<br />

LocalVarWTypes ::= LocalVarWType<br />

| ( LocalVarWType ( , LocalVarWType) + )<br />

LocalVarWType ::= [var ] Id IsType<br />

LocalVarWoTypes ::= LocalVarWoType<br />

| ( LocalVarWoType ( , LocalVarWoType) + )<br />

LocalVarWoType ::= [var ] Id<br />

| Unpasting<br />

Variables can be declared within block expressions (described in Section 13.11) via the same syntax as is used for<br />

top-level variable declarations (described in Section 6.2). A local variable declaration must not appear as the last of<br />

the block expression.<br />

6.4 Local Function Declarations<br />

Syntax:<br />

LocalVarFnDecl ::= Id ValParam [IsType] [Throws] = Expr<br />

Functions can be declared within block expressions (described in Section 13.11) via the same syntax as is used for toplevel<br />

function declarations (described in Chapter 12) except that locally declared functions must not include modifiers,<br />

contracts, static parameters, or where clauses (described in Chapter 11). As with top-level function declarations,<br />

locally declared functions in a single scope are allowed to be overloaded and mutually recursive. A local function<br />

declaration must not appear as the last of the block expression.<br />

6.5 Matrix Unpasting<br />

Syntax:<br />

Unpasting ::= [ L-Elt (Paste L-Elt) ∗ ]<br />

L-Elt ::= Id [[ L-ArraySize ]]<br />

| Unpasting<br />

L-ArraySize ::= L-Extent (×L-Extent) ∗<br />

L-Extent ::= Expr<br />

| Expr : Expr<br />

| Expr # Expr<br />

Paste ::= (Whitespace | ; ) +<br />

Matrix unpasting is an extension of variable declaration syntax as a shorthand for breaking a matrix into parts. On<br />

the left-hand side of a declaration, what looks like a matrix pasting of unbound variables is actually a declaration of<br />

58

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

Saved successfully!

Ooh no, something went wrong!