Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add os.nanoTime #849

Closed
wants to merge 3 commits into from
Closed

Add os.nanoTime #849

wants to merge 3 commits into from

Conversation

migeyel
Copy link

@migeyel migeyel commented Jul 5, 2021

This should be enough to close #818, though this is definitely the "interesting" way of doing it.

I'm very on the fence between this and adding an interface into a SecureRandom instance. While this feels like the natural-ish function to have in os, it still has some small details that I feel are inelegant for a standard library function. Meanwhile adding SecureRandom just feels wrong even though it's the "boring" (and thus desirable) way of doing it.

This adds a new function os.nanoTime which behaves exactly like the Java System.nanoTime, except that it overflows on 2^53 instead of 2^64 to maintain full precision as a double. This inherits all the Java edge cases as well as needing a modular reduction for properly compute a duration across timestamp overflows (Java's docs uses the long's overflow as a hidden modular reduction).

@SquidDev SquidDev added area-Core This affects CC's core (the Lua runtime, APIs, computer internals). enhancement An extension of a feature or a new feature. wontfix A bug which I won't fix or an enhancement which won't be implemented. labels Jul 14, 2021
@SquidDev
Copy link
Member

Sorry for the slow response - moved house this weekend, and so that's rather been dominating my life of late.

While I understand the motivation, I'm a bit iffy about exposing this sort of information to CC right now. It's a bit fourth-wall breaky and does feel like a bit of an awkward solution, so am not going to merge this.

@SquidDev SquidDev closed this Jul 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Core This affects CC's core (the Lua runtime, APIs, computer internals). enhancement An extension of a feature or a new feature. wontfix A bug which I won't fix or an enhancement which won't be implemented.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Supplying high-quality entropy to programs
2 participants