Skip to content

[P2] Random number generation: rand, rand-int, seeding #26

Description

@ecto

There is no randomness primitive today. This blocks tests, sims,
property-based testing, and most game/graphics demos.

Proposal

Expose randomness as a standard effect (consistent with IO,
Time, etc.) to keep it explicit and mockable:

[Rand.int 100]
[Rand.float]
[handle expr [Rand.int n] [resume 42]]

Add an entry point for seeding so tests can be deterministic.

Acceptance criteria

  • Effect declared in loon-lang with a default handler in the runtime.
  • Documented in ref/effects.loon.
  • A test that uses a custom handler to make Rand.int deterministic.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions