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.

Chapter 23<br />

Objects<br />

23.1 <strong>The</strong> Trait <strong>Fortress</strong>.Core.Object<br />

<strong>The</strong> trait Object is a single root of the type hierarchy; every object in <strong>Fortress</strong> has trait Object and therefore every<br />

object implements the methods of this trait.<br />

trait Object extends { EquivalenceRelationObject, =, IdentityOperatorObject }<br />

opr =(self,other: Object):Boolean<br />

opr IDENTITY(self):Object<br />

hash(maxval: N64): N64<br />

hash(maxval: N32): N32<br />

getter hashCode(): N64<br />

toString():String<br />

property ∀(x, y, n: N64) x = y → x.hash(n) = y.hash(n)<br />

property ∀(x, y, n: N32) x = y → x.hash(n) = y.hash(n)<br />

property ∀(x) x.hashCode = x.hash(2 64 − 1)<br />

property ∀(x, y) x = y → x.toString() = y.toString()<br />

end<br />

23.1.1 opr =(self,other: Object): Boolean<br />

<strong>The</strong> infix operator = (object equivalence) is used to decide whether two objects are “the same object” in the strictest<br />

sense possible; this is described in detail in Section 10.4.<br />

For ≠ = see Section 26.1.1.<br />

23.1.2 opr IDENTITY(self):Object<br />

<strong>The</strong> operator IDENTITY simply returns its argument. (This may not be terribly useful for applications programming,<br />

but it has technical uses for specifying contracts and algebraic properties in libraries as described in Section 37.3.)<br />

180

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

Saved successfully!

Ooh no, something went wrong!