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.

10.4 Object Equivalence<br />

<strong>The</strong> trait Object defines the object equivalence operator = . This operator is automatically defined for all objects;<br />

it is a static error for the programmer to override it. <strong>The</strong> = operator is used to decide whether its two arguments<br />

refer to “the same object” in the strictest sense possible. If the arguments have different dynamic types—including the<br />

instantiations of all static parameters—the result is always false . If both arguments are value objects with the same<br />

type, then the result is true if and only if corresponding fields of the objects are themselves equivalent as defined by<br />

this operator; in particular, two binary words are strictly equivalent if and only if they contain the same bit pattern. If<br />

both arguments are object references, then the result is true if and only if the two object references refer to the identical<br />

reference object (in implementation terms, occupying the same memory locations in the heap). If both arguments are<br />

functions, the result is true only if the functions behave identically for any choice of type-correct arguments. Even if<br />

two functions behave identically, the fortress implementation is free to return false when they are compared for object<br />

equivalence.<br />

80

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

Saved successfully!

Ooh no, something went wrong!