Skip to content

[Feat] compile-time random #2078

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

Open
BWindey opened this issue Apr 7, 2025 · 0 comments
Open

[Feat] compile-time random #2078

BWindey opened this issue Apr 7, 2025 · 0 comments

Comments

@BWindey
Copy link
Contributor

BWindey commented Apr 7, 2025

It would be cool to have compile-time variant of the current macros and functions providing random values at runtime. This should not be a complicated or particularly high entropy random generator, but could f.e. read out the needed bytes from /dev/random (on Unix) and insert them with the requested type in the code.

Example syntax:

int rand_nr = (int) $$RANDOM;

It could also be a function/macro (https://c3-lang.org/misc-advanced/builtins/), accepting ranges, types and/or length (amount bytes - usefull for array maybe?).

An alternative is using $exec() of course.

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

No branches or pull requests

1 participant