[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Bug? in mathlib's random()
- From: Dave Bollinger <DBollinger@...>
- Date: Sun, 22 Aug 1999 15:36:26 -0400
Another suggestion, if I may:
It would be nice if randomseed() also supported a zero-parameter form,
the purpose of which would be to seed the RNG with time of day, something
The trouble is, when using Lua as a stand-alone, there's no good way to
"randomly" seed the RNG -- date() returns a string, and clock() isn't
accurate enough, and trying to get some value via a call to execute() is
_OR_ consider adding a time() routine to the io library, so that
randomseed(time()) would be a legal call. The zero-param version seems
cleaner though if you'd prefer to avoid adding something new which might
cause a name conflict with existing code.
_OR_ have mathlib call srand() with time of day when initialized, so
that if NO call to randomseed() is made then you get a time-based seed,
specifying a particular seed would require an explicit call to
randomseed(). Though this could break code which assumed a particular seed
at startup, so not the preferred method.
Of course this could be easily added by anyone extending Lua, but I
think it might be worth considering as an official addition for anyone
using the stand-alone.