Email list hosting service & mailing list manager

SRFI 196 ready for finalization? John Cowan (27 Jul 2020 22:57 UTC)
Re: SRFI 196 ready for finalization? Wolfgang Corcoran-Mathe (28 Jul 2020 00:24 UTC)
Re: SRFI 196 ready for finalization? Marc Nieper-Wißkirchen (29 Jul 2020 06:59 UTC)
Re: SRFI 196 ready for finalization? John Cowan (29 Jul 2020 14:32 UTC)
Re: SRFI 196 ready for finalization? Wolfgang Corcoran-Mathe (29 Jul 2020 17:52 UTC)
Re: SRFI 196 ready for finalization? Wolfgang Corcoran-Mathe (29 Jul 2020 18:56 UTC)
Re: SRFI 196 ready for finalization? Arthur A. Gleckler (30 Jul 2020 05:50 UTC)
Re: SRFI 196 ready for finalization? Wolfgang Corcoran-Mathe (30 Jul 2020 17:03 UTC)
Re: SRFI 196 ready for finalization? Marc Nieper-Wißkirchen (30 Jul 2020 18:34 UTC)
Re: SRFI 196 ready for finalization? Arthur A. Gleckler (30 Jul 2020 20:17 UTC)
Re: SRFI 196 ready for finalization? John Cowan (30 Jul 2020 23:44 UTC)
Re: SRFI 196 ready for finalization? Marc Nieper-Wißkirchen (31 Jul 2020 06:14 UTC)
Re: SRFI 196 ready for finalization? Wolfgang Corcoran-Mathe (31 Jul 2020 17:33 UTC)
Re: SRFI 196 ready for finalization? Marc Nieper-Wißkirchen (31 Jul 2020 18:01 UTC)
Re: SRFI 196 ready for finalization? Wolfgang Corcoran-Mathe (31 Jul 2020 18:49 UTC)
Re: SRFI 196 ready for finalization? Marc Nieper-Wißkirchen (01 Aug 2020 06:55 UTC)
Re: SRFI 196 ready for finalization? John Cowan (01 Aug 2020 17:20 UTC)
Re: SRFI 196 ready for finalization? Marc Nieper-Wißkirchen (01 Aug 2020 19:14 UTC)
Re: SRFI 196 ready for finalization? Wolfgang Corcoran-Mathe (04 Aug 2020 22:35 UTC)
(missing)
Fwd: SRFI 196 ready for finalization? Marc Nieper-Wißkirchen (26 Aug 2020 19:12 UTC)
Re: Fwd: SRFI 196 ready for finalization? Wolfgang Corcoran-Mathe (26 Aug 2020 21:03 UTC)
Re: SRFI 196 ready for finalization? John Cowan (05 Aug 2020 02:02 UTC)
Re: SRFI 196 ready for finalization? John Cowan (05 Aug 2020 02:28 UTC)
Re: SRFI 196 ready for finalization? Wolfgang Corcoran-Mathe (05 Aug 2020 02:35 UTC)

Re: SRFI 196 ready for finalization? Wolfgang Corcoran-Mathe 29 Jul 2020 17:52 UTC

Thanks very much for the review, Marc!

On 2020-07-29 10:32 -0400, John Cowan wrote:
> On Wed, Jul 29, 2020 at 2:59 AM Marc Nieper-Wißkirchen <
> xxxxxx@nieper-wisskirchen.de> wrote:
> > - The implementation of "numeric-range" does seem to assume that
> > rounding errors cannot happen when computing the length. I think a
> > test has to be added whether "start + calculated-len * step < end" but
> > "start + (calculated-len - 1) * step >= end".
>
> Wolfgang, what do you think?

We should have

    end = (+ start (* calculated-len step))

since the last valid index is (- length 1).  If we replace
calculated-len with its definition, this is

    end = (+ start (* (/ (- end start) step) step)),

which is just reversing the computation and checking if we get
the same `end' that we were given.  This seems a little redundant,
but the overhead (at range creation time) is minimal; if it catches
some bad ranges, all the better.

The second constraint needs to be a little more complex, I think.
Since numeric ranges may be decreasing, or may be empty (start =
end), we need something like

    (assume
     (or (= start end)
         (if (< start end)
             (< (+ start (* (- calculated-len 1) step)) end)
             (> (+ start (* (- calculated-len 1) step)) end))))

In some quick tests, this is sufficient to catch problem ranges like

    (numeric-range 1 (expt 1000.0 10)).

There may be additional subtleties here.  Please correct me if I've
missed some.

I'll add both checks.

--
Wolfgang Corcoran-Mathe  <xxxxxx@sigwinch.xyz>

"Industry has surrounded people with artifacts whose inner workings
only specialists are allowed to understand." --Ivan Illich