Make default state public (#15763)
* Make default state public * Address review comments Co-authored-by: b3liever <b3liever@yandex.com>
This commit is contained in:
parent
0cae8ef2ca
commit
53d9902347
2 changed files with 7 additions and 1 deletions
|
|
@ -7,7 +7,7 @@
|
||||||
- `prelude` now works with the JavaScript target.
|
- `prelude` now works with the JavaScript target.
|
||||||
|
|
||||||
- Added `ioutils` module containing `duplicate` and `duplicateTo` to duplicate `FileHandle` using C function `dup` and `dup2`.
|
- 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
|
## Language changes
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,12 @@ else:
|
||||||
a0: 0x69B4C98CB8530805u64,
|
a0: 0x69B4C98CB8530805u64,
|
||||||
a1: 0xFED1DD3004688D67CAu64) # global for backwards compatibility
|
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 =
|
proc rotl(x, k: Ui): Ui =
|
||||||
result = (x shl k) or (x shr (Ui(64) - k))
|
result = (x shl k) or (x shr (Ui(64) - k))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue