-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Zachary Crockett
committed
Aug 31, 2014
1 parent
6dd0504
commit 4aeb054
Showing
1 changed file
with
4 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4aeb054
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WIth SYSTEM_MODE manual/semi-auto, the first cloud connection may happen sometime after the user app has already started using
random()
, and where the app may be expecting a specific sequence of numbers, such as ifsrand()
has already been called.With this in mind, it might be a good idea to allow users to opt-out of fetching a new random seed each time the cloud is connected. This can be done by defining a weak function to set the seed:
So the default behavior is to set the seed from the cloud, users have a way to opt-out of setting the random seed by defining this function as a no-op, or they can use the new seed in some other way that may be more appropriate to their use case.
4aeb054
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Thanks! Good thinking @m-mcgowan! Default should be to set from cloud during handshake, and then yes, there should be an easy way to opt out. With your suggestion, it sounds like the simplest user application code for opting out would be to add this line.
which basically says, "When the cloud gives me a new seed, do nothing with it, instead of actually calling srand."
This will be a rare choice among novices and more common among experts. I'm debating whether we should do anything to make it cleaner, e.g.,
#define NO_RANDOM_SEED_FROM_CLOUD
orSpark.ignoreRandomSeed()
.In writing them out these strike me just clutter compared to simply defining the no-op function (which allows usage of the seed for something else), but I'm open to other opinions.
4aeb054
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.