Make default state public (#15763)

* Make default state public

* Address review comments

Co-authored-by: b3liever <b3liever@yandex.com>
This commit is contained in:
Antonis Geralis
2020-10-29 12:14:22 +02:00
committed by GitHub
parent 0cae8ef2ca
commit 53d9902347
2 changed files with 7 additions and 1 deletions

View File

@@ -7,7 +7,7 @@
- `prelude` now works with the JavaScript target.
- Added `ioutils` module containing `duplicate` and `duplicateTo` to duplicate `FileHandle` using C function `dup` and `dup2`.
- Added `randState` template that exposes the default random number generator. Useful for library authors.
## Language changes

View File

@@ -119,6 +119,12 @@ else:
a0: 0x69B4C98CB8530805u64,
a1: 0xFED1DD3004688D67CAu64) # global for backwards compatibility
since (1, 5):
template randState*(): untyped =
## Makes the default Rand state accessible from other modules.
## Useful for module authors.
state
proc rotl(x, k: Ui): Ui =
result = (x shl k) or (x shr (Ui(64) - k))