You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
The first step is to make a prototype solution, once the Random module has been simplified to provide just a single type of random number generator. See also #19601
IMO it can and should be a plain record. The state is relatively small and can just be copied around. Also, it makes intuitive sense to me, if I copy an RNG, that I can advance each copy independently.
Should the random generator provided by the standard library be:
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?
The text was updated successfully, but these errors were encountered: