lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On 5/7/2018 12:27 AM, Roberto Ierusalimschy wrote:
Is it true ?
Lua 5.4 ?

That is our plan.

IMHO, math.random is similar in purpose to C standard library's
random function. It's pseudo-random, that's about it. It does not
promise any quality specifications.

My apologies for the ambiguity here and there. The likelihood is that I was not oblivious to the Lua 5.4.0 work1 discussion and here I was not trying to say that Lua should still use C stdlib's random function or anything like that. I was trying to make a connection between Lua's math.random and C standard library's random function in terms of what is offered, which is not much and nothing very specific.

So if anyone was planning to _rely_ on certain quality characteristics that happened to be present in the upcoming implementation (but is not actually guaranteed), then they'd better be very careful about doing so.

By "the current implementation" below I meant what was presented in the ongoing discussion. Poor writing/editing that.

Are there serious flaws that disqualifies the current implementation
from this purpose?

Yes. First, it is not portable. The C standard library 'rand' is so bad
that POSIX has another one. Lua uses that other one in POSIX systems,
but not in other platforms. That is, in some non-POSIX platforms
math.random can be really bad. Second, it does not generate 64-bit
numbers, which is strange now that Lua has 64-bit integers as its "main"
numeric type. (It is also a little weird that random floats do not have
all bits random. Someone complained about that not so long ago on the
[snip snip snip]

Kein-Hong Man (esq.)
Selangor, Malaysia