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

Recoverable random in infinite range #120

Open
oscbyspro opened this issue Oct 22, 2024 · 1 comment
Open

Recoverable random in infinite range #120

oscbyspro opened this issue Oct 22, 2024 · 1 comment
Labels
addition oh, so shiny! brrr such code, much wow maybe to do, or not to do?

Comments

@oscbyspro
Copy link
Owner

oscbyspro commented Oct 22, 2024

The range-based BinaryInteger.random(...) functions trap infinite ranges. It would be better to return nil. The current functions should be rewritten as unchecked conveniences with appropriate generic constraints.

@oscbyspro oscbyspro added addition oh, so shiny! brrr such code, much wow labels Oct 22, 2024
@oscbyspro oscbyspro added this to the Ultimathnum 0.11.0 milestone Oct 22, 2024
@oscbyspro oscbyspro changed the title Make random value in infinite range recoverable Make random in infinite range recoverable Oct 22, 2024
@oscbyspro
Copy link
Owner Author

oscbyspro commented Oct 23, 2024

Hm. I suppose there are arguments in favor of keeping the trapping behavior. In particular, picking a random value in an infinite range a lot like multiplying an arbitrary integer until you run out of memory. It isn't undefined. You just run out of memory, or at least that's what the trapping behavior emulates. It might be best to keep overallocation handling, or lack thereof, consistent across the board.

@oscbyspro oscbyspro added the maybe to do, or not to do? label Oct 23, 2024
@oscbyspro oscbyspro removed this from the Ultimathnum 0.11.0 milestone Oct 23, 2024
@oscbyspro oscbyspro changed the title Make random in infinite range recoverable Recoverable random in infinite range Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition oh, so shiny! brrr such code, much wow maybe to do, or not to do?
Projects
None yet
Development

No branches or pull requests

1 participant