在 2020年3月12日，23:58，Coda Highland <firstname.lastname@example.org> 写道：
> 在 2020年3月12日，22:39，Luiz Henrique de Figueiredo <email@example.com> 写道：
>> Is there any way to specify a seed when I create a new lua VM ? It's
>> very useful for reproduction of bugs .
>> If the seed is always random, the order of table iteration would be
>> different every time.
There is another reason that I want to set the seed by myself.
Our system use thousands lua VMs in one process. I make a small patch to share the function protos (including strings) among these VMs. So I need these VMs use the same seed, so that the strings’ hash can be used in any of these VM.
If you're already patching the VM, it shouldn't be hard to just patch the seed assignment yourself.
I don’t want to change the lua api , and my patch doesn’t change the any lua api but only the implementation.
And We can’t change(assign) the seed after lua_newstate . So I can only use a global seed, it’s ugly.