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.

38.2.4 getter hashCode(): Z64<br />

38.2.5 toString():String<br />

<strong>The</strong> toString method returns either “LessThan” or “EqualTo” or “GreaterThan” as appropriate.<br />

38.3 Top-level Total Comparison Values<br />

38.3.1 LessThan: TotalComparison<br />

38.3.2 EqualTo: TotalComparison<br />

38.3.3 GreaterThan: TotalComparison<br />

<strong>The</strong> immutable variables LessThan, EqualTo, and GreaterThan have as their values the three total comparison<br />

values that respectively signify whether a left-hand comparand is less than, equal to, or greater than a right-hand<br />

comparand. <strong>The</strong>y are top-level variables declared in the <strong>Fortress</strong> standard libraries.<br />

38.4 <strong>The</strong> Trait <strong>Fortress</strong>.Standard.Comparison<br />

When the comparison operator CMP is applied to values belonging to a partial order, rather than a total order, it typically<br />

returns a value of type Comparison, which includes the three values LessThan, EqualTo, and GreaterThan<br />

of type TotalComparison and also a fourth value, Unordered.<br />

This trait, like trait TotalComparison, supports an associative operator LEXICO that is useful for supporting lexicographic<br />

comparison of ordered sequences; the trick is to compare the sequences elementwise and then to use the<br />

LEXICO operator to reduce the sequence of comparison results. Note that EqualTo is the identity for LEXICO , and<br />

all other comparison values are left zeroes for LEXICO .<br />

value trait Comparison<br />

extends { IdentityEqualityComparison,<br />

AssociativeComparison,LEXICO,<br />

HasIdentityComparison,LEXICO,<br />

HasLeftZeroesComparison,LEXICO,isLeftZeroForLEXICO }<br />

comprises { TotalComparison, Unordered }<br />

opr LEXICO(self,other: Comparison): Comparison<br />

isLeftZeroForLEXICO(self):Boolean<br />

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

getter hashCode(): Z64<br />

toString():String<br />

end<br />

Unordered: Comparison<br />

267

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

Saved successfully!

Ooh no, something went wrong!