chicken-hackers
[Top][All Lists]
Advanced

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

Re: Exposing subsecond precision in current-seconds


From: Lassi Kortela
Subject: Re: Exposing subsecond precision in current-seconds
Date: Wed, 29 Apr 2020 15:23:15 +0300
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.7.0

- 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.

This seems best to me as well.

Thanks for the considerations.  I could imagine going with the following API 
based on SRFI-174, with `current-time` returning timespec records:

     (import (chicken base))
     (import (chicken time posix))
     (define now (current-time))
     (print "Current time: " (timespec->inexact now))
     (print "Current time: " (timespec-seconds now) "." (timespec-nanoseconds 
now))

Implementing the remaining parts of it should be no problem, the most tricky
part of it might be the `timespac-hash` procedure.  That way we'd have another
supported SRFI.

CC John Cowan who did most of the work on the timespec SRFI. Do you have a recommendation for a procedure to get the current time as a timespec?

We decided that time stuff is out of scope for SRFI 170 (a general POSIX SRFI from which 174 was spun off as its own self-contained SRFI). Nevertheless, it'd be good to have the same current-time procedure in all Schemes that implement 174.



reply via email to

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