Skip to content

Deprecate MathUtil.RANDOM shared mutable generator - #24

Merged
barrybecker4 merged 2 commits into
masterfrom
cursor/document-mathutil-random-3fbd
Nov 8, 2026
Merged

barrybecker4 merged 2 commits into
masterfrom
cursor/document-mathutil-random-3fbd

Conversation

@barrybecker4

@barrybecker4 barrybecker4 commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

Marks MathUtil.RANDOM as @deprecated (since 2.1) while keeping the public field so existing callers still compile.

RANDOM is a shared mutable fixed-seed (1) scala.util.Random and is not thread-safe. The deprecation message, Scaladoc, and README direct consumers to construct their own Random when they need isolation, a different seed, or concurrent access.

Searched this repo and the bb4 org for MathUtil.RANDOM: unused inside bb4-math, but widely used by bb4-games, bb4-puzzles, bb4-simulations, and bb4-optimization, so it was kept and deprecated rather than removed.

Fixes #22

Open in Web Open in Cursor 

cursoragent and others added 2 commits November 8, 2026 13:59
Keep the shared generator for downstream bb4 callers; document that it is
seeded with 1, is not thread-safe, and that callers should prefer a local
Random when isolation or concurrency matters.

Co-authored-by: Barry G Becker <barrybecker4@yahoo.com>
Keep the public field so existing callers still compile, but mark it
@deprecated since 2.1 so consumers get a compiler/IDE warning to use
their own Random instead of the shared mutable fixed-seed instance.

Co-authored-by: Barry G Becker <barrybecker4@yahoo.com>
@cursor cursor Bot changed the title Document MathUtil.RANDOM fixed seed and thread-safety Deprecate MathUtil.RANDOM shared mutable generator Nov 8, 2026
@barrybecker4
barrybecker4 merged commit b973846 into master Nov 8, 2026
1 check passed
@barrybecker4
barrybecker4 deleted the cursor/document-mathutil-random-3fbd branch November 8, 2026 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MathUtil.RANDOM is a shared mutable Random — confirm callers before removing

2 participants