Range Redesign: Empty Ranges

H. S. Teoh hsteoh at qfbox.info
Wed Mar 6 00:23:26 UTC 2024


On Wed, Mar 06, 2024 at 12:11:10AM +0000, Adam Wilson via Digitalmars-d wrote:
> On Tuesday, 5 March 2024 at 16:41:34 UTC, Alexandru Ermicioi wrote:
> > On Tuesday, 5 March 2024 at 14:39:17 UTC, Dom DiSc wrote:
> > > Are there infinite ranges that are indeed not forward ranges?
> > 
> > /dev/random could be such a range.
> 
> In the case of /dev/random I don't really see how it's a true
> infinity, you can't go infinitely backwards.

Nothing about an infinite range requires that it be infinite both ways,
unless it's a bidirectional range, which an RNG is not.


[...]
> Practically there is a limit to how much entropy you can grab off the
> the chip in single chunk, so it is a bounded range, it's just that the
> boundary is somewhat fuzzy.
[...]

A periodically-reseeded RNG is indeed a practically infinite range, with
no cycling.  You don't have to grab every value from the hardware
entropy source; it suffices to use a cryptographic hash function on a
counter that's periodically reseeded from the hardware entropy. It can
literally generate an endless stream of random numbers.


T

-- 
Tell me and I forget. Teach me and I remember. Involve me and I understand. -- Benjamin Franklin


More information about the Digitalmars-d mailing list