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.

Negating the literal 0 produces a special negative-zero object, which refuses to participate in compile-time constant<br />

arithmetic (discussed in Section 13.27). It has type NegativeZero. <strong>The</strong> main thing it is good for is coercion to a<br />

floating-point number (discussed in Chapter 17). (Negating any other zero-valued expression simply produces zero.)<br />

13.2 Identifier References<br />

Syntax:<br />

Expr ::= DottedName[StaticArgList ]<br />

| self<br />

DottedName ::= DottedId<br />

| opr Op<br />

A name that is not an operator appearing in an expression context is called an identifier reference. It evaluates to the<br />

value of the name in the enclosing scope in the value namespace. <strong>The</strong> type of an identifier reference is the declared<br />

type of the name. See Chapter 7 for a discussion of names. An identifier reference performs a memory read operation.<br />

Note in particular that if a name is not in scope, it is a static error (as described in Section 7.2).<br />

An identifier reference which denotes a polymorphic function may include explicit type arguments (described in<br />

Chapter 12) but most identifier references do not include them; the type arguments are statically inferred from the<br />

context of the method invocation (as described in Chapter 20). For example, identityString is an identifier reference<br />

with an explicit type argument where the function identity is defined as follows:<br />

identityT(x :T) :T = x<br />

<strong>The</strong> special name self is declared as a parameter of a method. When the method is invocated, its receiver is bound<br />

to the self parameter; the value of self is the receiver. <strong>The</strong> type of self is the type of the trait or object being<br />

declared by the innermost enclosing trait or object declaration or object expression. See Section 9.2 for details about<br />

self parameters.<br />

13.3 Dotted Field Accesses<br />

Syntax:<br />

Expr ::= Expr . Id<br />

An expression consisting of a single subexpression (called the receiver expression), followed by ‘.’, followed by a<br />

name, not immediately followed by a parenthesis, is a field access. If the receiver expression denotes an object (called<br />

the receiver), the field access is evaluated to a call to a getter mapped from that name by the receiver. <strong>The</strong> type of the<br />

field access is the return type of its getter. <strong>The</strong> static type of the receiver indicates whether a getter mapped from that<br />

name is provided by the denoted object. If a getter is not provided, it is a static error. See Section 9.2 for a discussion<br />

of getters.<br />

13.4 Dotted Method Invocations<br />

Syntax:<br />

Expr ::= Expr . Id[StaticArgList ]([ExprList])<br />

| TraitType.coercion[StaticArgList ](Expr)<br />

93

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

Saved successfully!

Ooh no, something went wrong!