Skip to content

Commit

Permalink
Make default state public (nim-lang#15763)
Browse files Browse the repository at this point in the history
* Make default state public

* Address review comments

Co-authored-by: b3liever <[email protected]>
  • Loading branch information
2 people authored and mildred committed Jan 11, 2021
1 parent 0348179 commit 4630541
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions lib/pure/random.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down

0 comments on commit 4630541

Please sign in to comment.