Pipo
Pipo

Reputation: 5093

Eiffel: is there a way to express a double implies clause in eiffel?

Like double bind in psychology, is there a way to tell that one expression implies another and reversely?

valid_last_error: attached last_error implies not attached last_success_message
valid_last_success_message: attached last_success_message implies not attached last_error

would be something like

valid_last_error: attached last_error double_binded_not attached last_success_message

which could be equivalent to

valid_last_error: attached last_error never_with attached last_success_message

implies (a, b: BOOLEAN): BOOLEAN

a b R
T T T
T F F
F T T
F F T

and (a, b: BOOLEAN): BOOLEAN

a b R
T T T
T F F
F T F
F F F

or (a, b: BOOLEAN): BOOLEAN

a b R
T T T
T F T
F T T
F F F

xor (a, b: BOOLEAN): BOOLEAN

a b R
T T F
T F T
F T T
F F F

double_implies (a, b: BOOLEAN): BOOLEAN

a b R
T T F
T F T
F T T
F F T

as a maybe more explaining example (more known) instead of writing

invalid_index_implies_off: index < 1 implies off
off_implies_invalid_index: off implies index < 1

we could write:

index_coherent_with_off: index < 1 never_both off

which would just add a function to BOOLEAN class such as

alias never_with, alias reversible_implies (v: like Current): like Current
    do
        if Current and v then
            Result := False
        else
            Result := True
        end
    end

Hope now everybody got my point... I don't know if there is such arithmetic operator.

We could extend it for a variable number of parameters

Upvotes: 0

Views: 92

Answers (1)

Pipo
Pipo

Reputation: 5093

The only answer for my question is to define a function in an util class like

feature -- could be in class BOOLEAN

double_implies, reversible_implies, never_both (a, b: BOOLEAN): BOOLEAN
        -- Into boolean class with never_with
    do
        if a and b then
            Result := False
        else
            Result := True
        end
    end

Upvotes: 0

Related Questions