New Issue: Random number generator - a class or a record?

19602, "vasslitvinov", "Random number generator - a class or a record?", "2022-04-05T20:06:52Z"

Should the random generator provided by the standard library be:

  • a class (which it currently is), or
  • a record, or
  • a record-wrapped class?

Issues to consider:

  • What do we want to be the initialization/assignment semantics -- duplicating the reference or copying? Many of our standard data structures perform copying. For a random number generator copying means starting at the same place. Whatever approach we take, semantics of when copies are made should be obvious to user.

  • What is the desired behavior for remote accesses? For example, what should fillRandom() do? Currently it creates a per-locale version.

  • If it is a class, it is easy for nilability or ownership issues to start biting the user. Although nilability is unlikely to become an issue because the user variable holding the class will likely be non-nilable.

  • If it is a record-wrapped class, what should be the ownership policy? This perhaps comes back to the above question on copy semantics. Having just a record seems simpler conceptually, easier to use.

  • If it is a record-wrapped class, how much additional complexity does this introduce for the implementer of another generator?