John M. Dlugosz wrote:
Please let me know if you see any coding errors, and of course any feedback is welcome.

Firstly, shouldn't there also be infinite strings? E.g. 'ab' x Inf
is a regularly infinite string and ~pi as well. Other classes might
have elaborate notions of infinity. The Complex e.g. might have an
angle associated to an Inf.

Secondly, you only have a single Inf constant and its negation. But
there should be a multitude of infinities. E.g. a code fragment

    my Int $a = random(0..1) > 0.5 ?? 3 !! Inf;
    my Int $b = $a + 1;
    say "yes" if $b > $a;

should always print "yes". That is we continue counting after Inf such
that we have transfinite ordinals.

    0, 1, 2, ..., Inf, Inf+1, Inf+2, ..., Inf*2, Inf*2+1, ...

The implementation is strait forward as an array of coefficients
of the Inf powers with Inf**0 == 1 being the finite Ints. The sign
bit goes separate from the magnitude. That is you can do the usual
Int arithmetic in the ranges Inf..^Inf*2 and -Inf*2^..-Inf except
that Inf has no predecessor and -Inf no successor. Well, and we lose
commutativity of + and *. I.e. 1 + $a != $a + 1 if $a is transfinite.

I'm not sure if such a concept of "interesting values of infinity"
is overly useful, though. In TeX e.g. there are infinitely stretchable
spacings of different infinitudes so that they overwrite each other.
Or take a stereographic projection near the point opposite of the
center of projection where you can usefully clip instead of getting
into funny folding of values into the valid range.

Also I think we can have finite conceptual infinities for types like
int32 and num64. In the latter case we also have infinitely small
values and "infinities" like sqrt(2). In short everything that falls
out of the finite range of these types and is captured in Int or Num.
BTW, with an infinite precision Num I see no need for the Rat type!

Regards, TSa.

"The unavoidable price of reliability is simplicity" -- C.A.R. Hoare
"Simplicity does not precede complexity, but follows it." -- A.J. Perlis
1 + 2 + 3 + 4 + ... = -1/12  -- Srinivasa Ramanujan

Reply via email to