Hello,

Considering this context of comparison operators:

    Generic   Num   Str
    -------------------
    =:=                   # equality (container)
    !=:=                  # negated equality (container)
    ===                   # equality (value, eternal semantics)
    !===                  # negated equality (value, eternal semantics)
    eqv       ==    eq    # equality (value, snapshot semantics)
    !eqv      !==   !eq   # negated equality (value, snapshot semantics)
              !=    ne    # traditional shortcuts for previous
              <     lt    # less than
              >     gt    # greater than
              <=    le    # less than or equal to
              >=    ge    # greater than or equal to
    cmp       <=>   leg   # lt => -1, eq => 0, gt => +1
    ~~                    # smart match (see smartmatch)
    !~~                   # negated smart match

It stands out that there seems to be no generic ordinal-relevant operators specifically for less-than, greater-than, etc, while there are such that cast their arguments as Num or Str.

While one can still emulate such operators on generic types using cmp (whose existence I am very glad for), I would like to propose that explicit less-than, greater-than etc exist partly for reasons of parity, so for example, one can take for example 2 Date-representing types and ask simply if one is earlier than the other, etc, and do this within the native type.

For simplicity, these operators would just work using snapshot semantics as, AFAIK, cmp and the Num and Str specific operators do.

Barring any better suggestions for names of such operators, I suggest we could follow a precedent laid down by eqv and name them: ltv, gtv, lev, gev (and also nev if that is useful); and we have visual consistency in that way.

On a tangential matter, I believe there should also be generic 'min' and 'max' type operators for all ordinal types, which would be useful in list summarizing activities; they would return the value from a list that would sort first or last. I don't see the reduce meta-operator as being applicable to this, since reducing using less-than eg, will return a boolean result. Unlike, say, 'avg' or 'sum', 'min' and 'max' are conceptually generic to all ordinal types.

So, is this workable?

-- Darren Duncan

Reply via email to