Skip to main content

Module random

Module random 

Source
Expand description

Random number generation intrinsics — full migration to typed marshal layer.

Per the intrinsics-typed-CC migration’s per-file table, all 5 random intrinsics (random, random_int, random_seed, random_normal, random_array) migrate to register_typed_fn_N typed entries via create_random_intrinsics_module.

Thread-local ChaCha8Rng state is observably-stateful FFI behavior at the runtime layer; the marshal-API surface treats each intrinsic as pure-from-thread-local (each call mutates RNG, returns f64/Unit/array). with_rng stays pub for shape-vm to share the same RNG state when delegating random/distribution/stochastic intrinsics to the runtime.

Provides high-quality PRNG using ChaCha8 for reproducibility and performance. Thread-local state ensures zero contention in parallel contexts.

Functions§

create_random_intrinsics_module
Create the random intrinsics module with all 5 typed-marshal entry points.
with_rng
Access the shared thread-local RNG.