Class PartialOrdering

java.lang.Object
org.ek9lang.compiler.support.PartialOrdering

public final class PartialOrdering extends Object
THE answer to "is this type's <=> PARTIAL?" - unset for some pair of SET values of the type (isPartial(ISymbol, ISymbol), whyPartial(ISymbol, ISymbol)). Two kinds, and only two:
  • a PARTIAL BUILT-IN (isPartialBuiltIn(ISymbol)): defined only within a group of its own values and unset between groups (a currency for Money, a unit suffix for Dimension);
  • a developer's type whose values can be of DIFFERENT run-time types under a per-type sameness - an open or abstract class, record or component, or a trait, with no <=> written by hand on an abstract base or trait (Sameness.mayMixRuntimeTypes(IAggregateSymbol, ISymbol), the test behind E07187): two values of different run-time types have an unset <=> (D24 rule 3; Steve, 2026-10-27, "extend E07188"). Whether a sub-type exists yet is not asked - as for E07187, a later module can add one.

The built-in kind is DECLARED by the type implementing org.ek9.lang.ComparisonGroup in the runtime; the compiler reads that declaration, it never lists type names (Steve, 2026-10-21, sameness stock-take 4.4: "the only partial built-ins are Money and Dimension, declared on the type"). Only that kind gets phase 7's unset case for <? and >? (isPartialBuiltIn(ISymbol)); the other kind is refused there by E07187.

Every other <=> is TOTAL: it orders every two SET values. A user type's own is judged separately - a hand-written one by phase5/OrderingTotality (E07188, which asks isPartial(ISymbol, ISymbol) of each <=> it is built on), a defaulted one by Sameness.orderingSurvives(MethodSymbol, ISymbol), which fails when a field's type is partial.

Never test for Money or Dimension by name or class in the compiler - a new built-in with this property implements the interface and this class sees it.

  • Method Details

    • isPartialBuiltIn

      public static boolean isPartialBuiltIn(ISymbol type)
      True when the type is a core built-in whose runtime class declares a comparison group.
      Parameters:
      type - the type asked about, may be null
      Returns:
      true for Money and Dimension; false for everything else, user types included
    • isPartial

      public static boolean isPartial(ISymbol type, ISymbol ek9Any)
      THE test of whether a <=> of this type can be unset for two SET values of it: a partial built-in, or a type whose values may be of different run-time types under a per-type sameness. A generic's bare T is never judged here (it is judged where it is substituted, or left to the run time).
      Parameters:
      type - the type asked about, may be null
      ek9Any - the Any type
      Returns:
      true when its <=> is partial
    • whyPartial

      public static Optional<String> whyPartial(ISymbol type, ISymbol ek9Any)
      THE wording of why a type's <=> is partial (isPartial(ISymbol, ISymbol)), to follow "'X' ...", or empty when it is total.
      Parameters:
      type - the type asked about, may be null
      ek9Any - the Any type
      Returns:
      the reason, if its <=> is partial