<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 4, 2017, at 3:21 AM, Haravikk via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" class=""><div class=""><br class="Apple-interchange-newline">On 4 Mar 2017, at 06:58, Charlie Monroe via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">While I am not against the idea, I believe that this is not as easy as one would think as everyone has a different understanding of the word "random" as most of random generators aren't "true" random generators.<br class=""><br class="">I think this would ideally require a new protocol RandomGenerator which would be passed to the collection to get the random element, i.e. it would look something like:<br class=""><br class="">arr.randomElement(using: ARC4RandomGenerator())<br class=""></div></div></blockquote></div></div></blockquote><div><br class=""></div>Agreed. Probably the best random interface would just allow one to fetch one or more bytes of ‘randomness’, then apply however best toward making a number</div><div><br class=""><blockquote type="cite" class=""><div class=""><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">I suppose the question is whether a default PRNG on numeric types is "good enough", since most developers just need<span class="Apple-converted-space"> </span><i class="">some</i><span class="Apple-converted-space"> </span>randomness, it doesn't matter how good it actually is. Anyone with stricter requirements shouldn't be using a black-box, default generator.</div></div></blockquote><div><br class=""></div>In general, I’d recommend against providing a default that we know won’t meet everyone’s needs, as randomness can have security properties. There are also use cases (like games) where it is important to have multiple identical sources of random data.</div><div><br class=""></div><div>A Numeric init(using: RandomSource:, range: Range<Self>) or similar may be more appropriate, but this might be better served as a future extension to be done in conjunction with the server api working group (who I believe are currently working on security/cryptography).</div><div><br class=""></div><div>-DW </div><div><br class=""></div></body></html>