hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 074324941227caa8df7f513f32d431d400c5b03a
parent efc49cf4f4ad16986ad056abe2c0bdb9bc769e55
Author: Drew DeVault <sir@cmpwn.com>
Date:   Wed, 13 Apr 2022 13:57:17 +0200

time::compare: improve docs

Signed-off-by: Drew DeVault <sir@cmpwn.com>

Diffstat:
Mtime/arithm.ha | 18++----------------
Mtime/chrono/chronology.ha | 6------
2 files changed, 2 insertions(+), 22 deletions(-)

diff --git a/time/arithm.ha b/time/arithm.ha @@ -15,22 +15,8 @@ export fn diff(a: instant, b: instant) duration = { return ((b.sec - a.sec) * SECOND) + (b.nsec - a.nsec); }; -// Returns: -// -1 if a precedes b; -// 0 if a and b are simultaneous; -// +1 if b precedes a; -// -// XXX: -// At first seems superceded by elapsed, but useful when you need values at -// compile time: -// switch (compare(a, b)) { -// case -1 => ...; -// case 0 => ...; -// case 1 => ...; -// case => abort("Unreachable") -// }; -// -// Would it be better as an enum, to avoid that abort()? +// Returns -1 if a precedes b, 0 if a and b are simultaneous, or +1 if b +// precedes a. export fn compare(a: instant, b: instant) i8 = { return if (a.sec < b.sec) -1 else if (a.sec > b.sec) 1 diff --git a/time/chrono/chronology.ha b/time/chrono/chronology.ha @@ -61,12 +61,6 @@ export fn to_instant(m: moment) time::instant = { // Interpreted with an appropriate timescale like utc, tai, gps. export def EARTH_DAY: time::duration = 86400 * time::SECOND; -// The following are temporary constants for demonstration of non-terrestrial -// timescales as proof of feasibility, and should probably be moved to a -// third-party martian:: library. -// -// TODO: figure out a future-proof naming convention. - // The temporal length of a solar day on Marth, in Martian seconds export def MARS_SOL_MARTIAN: time::duration = 86400 * time::SECOND;