Skip to content

Implement #split and #split_internal as per stdlib (proposal)#1

Open
ysbaddaden wants to merge 1 commit intomainfrom
fix/stdlib-split
Open

Implement #split and #split_internal as per stdlib (proposal)#1
ysbaddaden wants to merge 1 commit intomainfrom
fix/stdlib-split

Conversation

@ysbaddaden
Copy link
Owner

No description provided.

@ysbaddaden ysbaddaden self-assigned this Nov 7, 2025
@ysbaddaden ysbaddaden added the enhancement New feature or request label Nov 7, 2025
straight-shoota pushed a commit to crystal-lang/crystal that referenced this pull request Nov 9, 2025
…6342)

Adds a couple methods to formalize the API for splitting a `Random` instance:

- `Random#split`: splits the instance by allocating a new instance.
- `#split_internal`: splits the instance into an allocated instance (for example `ReferenceStorage(T)`).

I initially wanted a `#split!` method with no argument, but we need access to both instances to avoid splits (and re-splits of splits) to end up sharing the same sequences.

Extracted from #16174 and adapted with usages in the [random shard](ysbaddaden/random.cr#1, XoShiRo).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant