Finally getting around to watching all the talks, all good stuff :) Figured I'd make a thread talking about things I came across and perhaps get into a discussion on them in detail.

Anyways I'm watching the talk with Joseph Wakeling involving RNG and I wonder, is that still a problem or not?

I ask since the simplest and most correct thing I can think of is to use the heap for a referenced state, and dup would then duplicate the state properly while otherwise the RNG problems go away that most of the talk went on about.

It's possible I've been out of the loop and this has already been solved. Not sure yet, I haven't looked closely at any of the sources or the language updates.

 So... time for some rusty D prototyping.

[code]
struct RNG {
  int* state;

  this(int seed) {
    state = new int;
    *state = seed;
  }

//if you provide a pointer, we don't rely on the heap/gc at all...
  //maybe a small stack based allocator could be useful for this?
  this(int* seed) { state = seed; }

  //dup instead of save, so it's not a forward range
  RNG dup() { return RNG(*state); }

  //popfront, front & empty as expected
}
[/code]

Reply via email to