[Top][All Lists]

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

Re: [RFC] `time' builtin

From: Jose E. Marchesi
Subject: Re: [RFC] `time' builtin
Date: Mon, 09 Nov 2020 09:07:49 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

>> So we need a `time' builtin function to get the time :)
>> The main motivation is to build seeds for the already existing `rand':
>>   fun rand = (uint<32> seed = 0) int<32>:
>> Now the question is: what would be a good prototype for `time'?  What
>> should it return?  We could:
>> a) Make it return seconds since the Epoch, or
>> b) something more elaborated and precise like a struct tm.
>> Note that we already have a `ptime' function in the standard library
>> that gives a date in seconds since the Epoch prints a human-readable
>> version of it:
>>   fun ptime = (uint<64> seconds) void:
>> So maybe a) is more than enough... thoughts?
> I think `struct timespec` is a better option, because
>   1) it only has two fields (one for seconds and one for nanoseconds)
>   2) Using the nanoseconds part is also useful for seeding the `rand`.
>      (Disclaimer: I'm not an expert in pseudo-random number generators)
> ```poke
> type timespec = struct
>   {
>     uint<64> sec;
>     uint<64> nsec;
>   };
> ```

Sounds good.  We can call the builtin gettime.
Thanks for the feedback!

reply via email to

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