On Thursday, 20 March 2014 at 01:32:41 UTC, Chris Williams wrote:
On Wednesday, 19 March 2014 at 23:49:41 UTC, Joseph Rushton Wakeling wrote:
Hello all,

As some of you may already know, monarch_dodra and I have spent quite a lot of time over the last year discussing the state of std.random. To cut a long story short, there are significant problems that arise because the current RNGs are value types rather than reference types.

Any chance that you could describe them? I was about to resume porting the dcrypt library into Phobos, and had intended to flip the classes into structs, to match what the rest of the library was doing.

The issue isn't class vs struct, but rather "value semantic" vs "reference semantic" (classes are always ref, but structs can be either). Basically, if you make a copy, and modify the copy, will the original range be modified?

The problem with "value semantics" is that it always un-expected duplication of the range, which is a critical blocker problem as far as random goes.

The tell-tale usecase is:

    auto g = rndGen();

This will write the same sequence... TWICE!

Reply via email to