[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Exposing subsecond precision in current-seconds

From: felix . winkelmann
Subject: Re: Exposing subsecond precision in current-seconds
Date: Mon, 27 Apr 2020 21:26:45 +0200

> - Change `current-seconds` to use `gettimeofday` in a way that combines both
>   seconds and nanoseconds into a double (that should be plenty precision).  On
>   Windows a replacement could be defined like with PostgreSQL [1].  Or maybe
>   don't bother giving Windows users an enhanced experience and return an
>   integer here.

That would break a lot of code. "current-seconds" is fine for UNIX timestamps,
which, I guess, is the most frequent usage.

> - Add a new procedure in `(chicken time)` or `(chicken time posix)` that gives
>   you both seconds and nanoseconds, be it as values, list, vector, ...  Same
>   Windows considerations as previously apply.

Probably the best solution, I guess something based on "clock_gettime"
is the most precise and portable method, even though it may need librt on
some platforms.

> - Bonus: Make `current-seconds` return two values, the seconds and 
> nanoseconds.
>   Previously written code should continue to function unchanged.  I don't
>   really like this idea though, it's a bit too magic and kind of cumbersome
>   to use.

Same here as point #1, due to incompatibiltiy (and, no, we should not rely
on surplus values being thrown away).


reply via email to

[Prev in Thread] Current Thread [Next in Thread]