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

[Docs] the "random" module should not be imported by default #3076

Open
forFudan opened this issue Jun 18, 2024 · 2 comments
Open

[Docs] the "random" module should not be imported by default #3076

forFudan opened this issue Jun 18, 2024 · 2 comments
Labels
mojo-repo Tag all issues with this label

Comments

@forFudan
Copy link

forFudan commented Jun 18, 2024

Where is the problem?

https://docs.modular.com/mojo/stdlib/random/random/

What can we do better?

According to the official documentation, the random module needs to be imported before use.

You can import these APIs from the random package. For example:

from random import seed

But the following code work without error:

fn main():
    var arr = random.randn_float64()
    print(arr)

I would prefer to make the module to be not imported by default, being consistent with the documentation, and makes the naming space cleaner.

Anything else?

No response

@forFudan forFudan added documentation Improvements or additions to documentation mojo-repo Tag all issues with this label labels Jun 18, 2024
@gabrieldemarmiesse
Copy link
Contributor

gabrieldemarmiesse commented Jun 19, 2024

Thanks for the issue! I think it's a duplicate of #2529 . Can you confirm? If yes, I believe this issue can be closed and we'll keep #2529 opened as it's a more general issue of the relationship between the compiler and the stdlib.

@forFudan
Copy link
Author

Thanks for the issue! I think it's a duplicate of #2529 . Can you confirm? If yes, I believe this issue can be closed and we'll keep #2529 opened as it's a more general issue of the relationship between the compiler and the stdlib.

I think they are different issues. The example in #2529 is conditional on the fact that someone, by mistake, imports now() into any of the builtin files. However, the random module is always imported automatically, even without user changing the builtin files.

@ematejska ematejska removed the documentation Improvements or additions to documentation label Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mojo-repo Tag all issues with this label
Projects
None yet
Development

No branches or pull requests

3 participants