Removed the Compare trait

This trait is not particularly useful in its current implementation, and
was only used by Integer, Float, and Range. For Range it wasn't even
necessary, as Range only needs Successor and SmallerOrEqual.
parent 544b1664
#! Functionality for comparing objects.
import std::operators::(Equal, Smaller, SmallerOrEqual, Greater, GreaterOrEqual)
## Trait for more easily requiring all comparison operators to be implemented.
trait Compare: Equal + Smaller + SmallerOrEqual + Greater + GreaterOrEqual {}
......@@ -2,7 +2,6 @@
#!
#! Floats are implemented as IEEE 754 floats.
import std::compare::Compare
import std::conversion::(ToInteger, ToString, ToFloat)
import std::error::StandardError
import std::hash::(Hasher, Hash)
......@@ -72,8 +71,6 @@ impl SmallerOrEqual for Float {
}
}
impl Compare for Float {}
impl Numeric for Float {
def negative? -> Boolean {
self < 0.0
......
#! The integer type.
import std::compare::Compare
import std::conversion::(ToInteger, ToString, ToFloat)
import std::error::StandardError
import std::hash::(Hasher, Hash)
......@@ -116,8 +115,6 @@ impl ShiftRight for Integer {
}
}
impl Compare for Integer {}
impl Numeric for Integer {
def negative? -> Boolean {
self < 0
......
#! Range data types and methods.
import std::compare::Compare
import std::conversion::ToArray
import std::operators::(Equal, SmallerOrEqual)
import std::successor::Successor
......@@ -15,8 +14,8 @@ import std::successor::Successor
## A `Range` supports a start and end value of any type as long as:
##
## 1. They are both of the same type.
## 2. Both implement the `Successor` and `Compare` traits.
object Range!(T: Successor + Compare) impl Equal, ToArray!(T) {
## 2. Both implement the `Successor` and `SmallerOrEqual` traits.
object Range!(T: Successor + SmallerOrEqual) impl Equal, ToArray!(T) {
def init(start: T, end: T) {
let @start = start
let @end = end
......@@ -70,7 +69,7 @@ object Range!(T: Successor + Compare) impl Equal, ToArray!(T) {
}
}
trait ToRange!(T: Successor + Compare) {
trait ToRange!(T: Successor + SmallerOrEqual) {
## Returns a `Range` starting at `self` up to (and including) `other`.
def ..(other: T) -> Range!(T)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment