Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

importing tempfile breaks expected behaviour of std / random #13

Open
pietroppeter opened this issue Apr 1, 2023 · 7 comments
Open

Comments

@pietroppeter
Copy link

module random from stdlib requires a call to randomize in order to have random results that change at every call. Indeed the following:

import std / random
echo rand(100)

produces always the same number when run again (on my machine: 3).

If tempfile is imported instead the behaviour changes, since indeed tempfile calls randomize in its global space. so the following:

import std / random
import tempfile
echo rand(100)

will produce always different numbers.

Is it necessary to have this randomize call or could it be removed (or hidden behind the switch and documented this behaviour)?

Btw, I have been happily using tempfile as a dependency in nimib since its beginning, thanks for creating this!

@ba0f3
Copy link
Collaborator

ba0f3 commented Apr 2, 2023

please consider this module is deprecated since tempfiles module added to Nim standard library https://nim-lang.github.io/Nim/tempfiles.html

@pietroppeter
Copy link
Author

Ok we will switch to temp files from stdlib. Should I make a Pr to add this deprecation notice to the readme?

@ba0f3
Copy link
Collaborator

ba0f3 commented Apr 2, 2023

I will do it soon, and remove it from Nimble directory too. Thank you!

@pietroppeter
Copy link
Author

Well if you can wait to remove it from nimble until we make the fix on our side... otherwise it will break anyone trying to install nimib :)

@ba0f3
Copy link
Collaborator

ba0f3 commented Apr 2, 2023

Ofcourse I can wait :)

@pietroppeter
Copy link
Author

And there might be other libraries depending on it, maybe you could add a deprecation notice to appear when the library is installed/used and remove from nimble after a deprecation period?

@ba0f3
Copy link
Collaborator

ba0f3 commented Apr 2, 2023

its ok, so I will archive this project only.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants