Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PRNG qsystem lib #769

Open
ss2165 opened this issue Jan 15, 2025 · 4 comments
Open

Add PRNG qsystem lib #769

ss2165 opened this issue Jan 15, 2025 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@ss2165
Copy link
Member

ss2165 commented Jan 15, 2025

Module name: guppylang.std.random

Functions:
Note we should not use names from the python standard library random because they have different signatures and behaviours

@guppy.struct
class RNGContext:
  # can only be initialised once per program. Second init fails at rutime.
  def __init__(seed: int) -> "RNGContext": ...
  # init safely, returning None if already acquired.
  def init_safe(seed: int) -> Option["RNGContext"]: ...
  def random_nat(self) -> nat: ...
  def random_int(self) -> int: ...
  def random_float(self) -> float: ...
  def random_int_bounded(self, bound: int) -> int: ...
@qartik qartik self-assigned this Feb 19, 2025
@qartik
Copy link
Member

qartik commented Feb 20, 2025

Module name: guppylang.std.random

Should random be namespaced under qsystem module or std?

@ss2165
Copy link
Member Author

ss2165 commented Feb 21, 2025

probably safer to go with qystem for now

@qartik
Copy link
Member

qartik commented Feb 21, 2025

def random_nat(self) -> nat: ...

is this just an alias for random_int with some type conversions?

@qartik qartik changed the title Add PRNG standard lib Add PRNG qsystem lib Feb 21, 2025
@ss2165
Copy link
Member Author

ss2165 commented Feb 21, 2025

is this just an alias for random_int with some type conversions?

yup

@qartik qartik added the enhancement New feature or request label Feb 21, 2025
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

No branches or pull requests

2 participants