1. 41
  1.  

  2. 2

    new implementation for math.random

    From reading git history I see Lua switched from calling out to C random/srandom or rand/srand (depending on posix) to xorshift128+ and then to xoshiro256**. That’s a nice change, but I’m a little surprised why a PCG-family non-CSPRNG algorithm wasn’t used: https://www.pcg-random.org/posts/a-quick-look-at-xoshiro256.html

    PCG XSL RR 128/64 (MCG) could be used for 64-bit values (albeit with period 2^126 compared to xoroshiro256**’s 2^256 − 1) with 128 bits. Half the state size than xoshiro256**, and the performance might be comparable (would need benchmarking). LCG version if you want to trade PRNG quality for even more speed.

    1. 2

      To-be-closed variables, nice!

      https://www.lua.org/manual/5.4/manual.html#3.3.8

      The gotchas for coroutines are also interesting, e.g. the coroutine.close method.

      [disclaimer: I barely know lua]

      1. 1

        I’m just excited for const variables!

        1. 2

          Constant variables fell out of the implementation of to-be-closed variables. As such, you can only mark local variables const, and it’s the variable that is constant, not the value. You can’t reassign the variable to a new value, but if the value is a table, the table itself can be modified.

          1. 1

            Thanks for the clarification!