Beispiel #1
0
def eq_default(a, b):
    # This strongly enforces the null and boolean identity.
    # You can't mess it up by multimethod introductions.
    if a == null or b == null:
        return boolean(a == b)
    elif isinstance(a, Boolean) or isinstance(b, Boolean):
        return boolean(a == b)
    # This reflects how the cmp_ operates, with an exception that
    # if cmp cannot succeed, we will use the identity equality.
    args = [a, b]
    method = cmp_.fetch_method(args, True)
    if method is None:
        c = coerce.fetch_method(args, False)
        if c is not None:
            args = cast(c.call(args), List,
                        u"coerce should return a list").contents
            method = cmp_.fetch_method(args, True)
    if method is not None:
        return boolean(
            cast(method.call(args), Integer, u"cmp should return an int").value
            == 0)
    else:
        # This way, the equality and inequality is always defined,
        # even if comparison is not defined for everything.
        return boolean(a == b)
Beispiel #2
0
def ge_default(a, b):
    args = [a, b]
    method = cmp_.fetch_method(args, True)
    if method is not None:
        return boolean(
            cast(method.call(args), Integer, u"cmp should return int").value >=
            0)
    else:
        args = cast(coerce.call(args), List, u"coerce should return a list")
        return ge.call_suppressed(args.contents)
Beispiel #3
0
def _(a, b):
    return boolean(a.value == b.value)
Beispiel #4
0
def ne_default(a, b):
    return boolean(is_false(eq.call([a, b])))
Beispiel #5
0
def cmp_le(a, b):
    return boolean(a.number <= b.number)
Beispiel #6
0
def cmp_lt(a, b):
    return boolean(a.number < b.number)
Beispiel #7
0
def cmp_le(a, b):
    return boolean(a.value <= b.value)
Beispiel #8
0
def _(a, b):
    return boolean(a.string == b.string)
Beispiel #9
0
def cmp_le(a, b):
    return boolean(a.number <= b.number)
Beispiel #10
0
def cmp_gt(a, b):
    return boolean(a.number > b.number)
Beispiel #11
0
def cmp_lt(a, b):
    return boolean(a.number < b.number)
Beispiel #12
0
def cmp_ge(a, b):
    return boolean(a.value >= b.value)
Beispiel #13
0
def cmp_le(a, b):
    return boolean(a.value <= b.value)
Beispiel #14
0
def cmp_gt(a, b):
    return boolean(a.value > b.value)
Beispiel #15
0
def cmp_lt(a, b):
    return boolean(a.value < b.value)
Beispiel #16
0
def _(a, b):
    return boolean(a.number == b.value)
Beispiel #17
0
def _(a, b):
    return boolean(a.ref == b.ref)
Beispiel #18
0
def cmp_ge(a, b):
    return boolean(a.number >= b.number)
Beispiel #19
0
def cmp_gt(a, b):
    return boolean(a.value > b.value)
Beispiel #20
0
def ne_default(a, b):
    return boolean(a != b)
Beispiel #21
0
def cmp_ge(a, b):
    return boolean(a.value >= b.value)
Beispiel #22
0
def eq_default(a, b):
    return boolean(a == b)
Beispiel #23
0
def cmp_gt(a, b):
    return boolean(a.number > b.number)
Beispiel #24
0
def _(a, b):
    return boolean(a.value == b.value)
Beispiel #25
0
def cmp_ge(a, b):
    return boolean(a.number >= b.number)
Beispiel #26
0
def _(a, b):
    return boolean(a.number == b.number)
Beispiel #27
0
def _(a, b):
    return boolean(a.number != b.number)
Beispiel #28
0
def _(a, b):
    return boolean(a.eq(b))
Beispiel #29
0
def ne_default(a, b):
    return boolean(a != b)
Beispiel #30
0
def eq_default(a, b):
    return boolean(a == b)
Beispiel #31
0
def _(a, b):
    return boolean(a.value == b.number)
Beispiel #32
0
def _(a, b):
    return boolean(a.eq(b))
Beispiel #33
0
def _(a, b):
    return boolean(a.string == b.string)
Beispiel #34
0
def cmp_lt(a, b):
    return boolean(a.value < b.value)
Beispiel #35
0
def cmp_eq(a, b):
    return boolean(a.eq(b))
Beispiel #36
0
def ne_default(a, b):
    return boolean(is_false(eq.call([a, b])))