Class RangeProgressCheck

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

public final class RangeProgressCheck extends Object
THE decision of which for-range counter types get a run-time PROGRESS CHECK (Steve, 2026-10-21): after each step the counter must have moved toward the end - ascending new <=> previous > 0, descending < 0 - and when it did not (it wrapped, stayed equal, or the comparison is unset) the range ends. So a range never loops forever because its step fails to move toward the end.

Only a counter type whose step CAN wrap or not move needs it:

  • Time, the one built-in that wraps (clock arithmetic: 23:55 + PT10M is 00:05); a constrained type over Time is counted in Time (its _base()), so it is asked as Time;
  • Float and Dimension, which stall at 2^53 (below);
  • every USER-defined range type, whose +=, ++ or -- may wrap or not move.

Almost every other core type goes UNSET at its limit (the Math.*Exact family, Character's validity, an enumeration's boundary) and an unset counter already ends the loop, so they get NOTHING - their IR and bytecode are unchanged. An enumeration, user-defined or not, is one of those. Decided here, at compile time, from SYMBOLS (never a type name), and carried in the IR as progress_check: a back end never re-derives which types need it.

Float and Dimension (a double) do NOT go unset: they STALL once the counter's magnitude reaches 2^53, where adding 1 (or a small by step) no longer changes it, so 9007199254740990.0 ... 9007199254741000.0 printed one value for ever. Steve (2026-10-21) added them: a stalled counter did not move, so the range ends. A constrained type over either is counted in its base, so it is asked as the base.

  • Method Details

    • isNeededFor

      public static boolean isNeededFor(ISymbol counterType, ISymbol ek9Time, ISymbol ek9Float, ISymbol ek9Dimension)
      True when a for-range counted in counterType (already resolved to the concrete type, the base of a constrained one) carries a progress check. The other three are the built-ins that can wrap or stall: Time, Float and Dimension.