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

Allow to set the seed for the random number generator #2705

Open
elia opened this issue Jul 26, 2018 · 4 comments
Open

Allow to set the seed for the random number generator #2705

elia opened this issue Jul 26, 2018 · 4 comments

Comments

@elia
Copy link

@elia elia commented Jul 26, 2018

In the original Sass it was possibile to do that with:

Sass::Script::Functions.random_seed = 1 

Example usage:

> Sass::Script::Functions.random_seed = 1 
=> 1
> Sass::Engine.new("body\n  asdf: random(100)", style: :compressed).render
=> "body{asdf:38}\n"
> Sass::Script::Functions.random_seed = 1 
=> 1
> Sass::Engine.new("body\n  asdf: random(100)", style: :compressed).render
=> "body{asdf:38}\n"

Also from what I see the sass-spec uses a workaround to test random numbers, where the ability to set a seed would probably improve the quality of those tests.

partially related issues:

@nschonni

This comment has been minimized.

Copy link
Collaborator

@nschonni nschonni commented Jul 26, 2018

@nex3 is this something for the language spec?

@nex3

This comment has been minimized.

Copy link
Contributor

@nex3 nex3 commented Jul 26, 2018

No, I think this can be left up to the host language's API.

@NiciusB NiciusB mentioned this issue Sep 30, 2018
@mgreter

This comment has been minimized.

Copy link
Contributor

@mgreter mgreter commented Dec 14, 2018

I think the use case has some merit, but on the other hand I think that it kinda defeats the merits of being really "random". Marking it as a feature request, but given that this would need to populate down to wrappers don't expect anything anytime soon.

@saper

This comment has been minimized.

Copy link
Member

@saper saper commented Oct 22, 2019

As I wrote in sass/node-sass#2503 (comment) we need to understand better how it possibly should work. Even if PRNG is initialized once per sass_compile_data_context call, we should make sure the order of includes and mixins remains stable and predictable. And maybe other things that my kill reproducibility of the generated values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.