[CM] s7 does not measure seconds correctly

Rudolf Adamkovič salutis at me.com
Wed Nov 30 16:38:28 PST 2022


bil at ccrma.Stanford.EDU writes:

> (define (jiffies-per-second) 1000000000)
> (define (current-jiffy)
>    (with-let *libc*
>      (let ((res (clock_gettime CLOCK_MONOTONIC)))
>        (+ (* 1000000000 (cadr res)) (caddr res)))))
> (define (current-second) (* 1.0 ((*libc* 'time) (c-pointer 0 
> 'time_t*))))

I have not tried the code yet, but I have noticed that per POSIX, the
CLOCK_MONOTONIC type measures since "some unspecified point in the
past".  On Linux, it measures the time since the last boot, for
instance.

If so, then even if the current-second correctly "ticks" once per
second, the number returned from the `current-second' procedure would
still deviate from the expected value, as per R7RS.  As a result, any
R7RS code that actually needs *correct* time would break.

Rudy
-- 
"Simplicity is complexity resolved."
-- Constantin Brâncuși, 1876-1957

Rudolf Adamkovič <salutis at me.com> [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



More information about the Cmdist mailing list