<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Nov 30, 2017, at 5:21 PM, Xiaodi Wu via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">On Thu, Nov 30, 2017 at 5:24 PM, Nate Cook <span dir="ltr" class="">&lt;<a href="mailto:natecook@apple.com" target="_blank" class="">natecook@apple.com</a>&gt;</span> wrote:<br class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space" class=""><div class=""><span class=""><blockquote type="cite" class=""><div class="">On Nov 30, 2017, at 4:30 PM, Xiaodi Wu via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_5971727561394076537Apple-interchange-newline"><div class=""><div dir="ltr" class="">On Thu, Nov 30, 2017 at 3:58 PM, Dave DeLong via swift-evolution <span dir="ltr" class="">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;</span> wrote:<br class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto" style="word-wrap:break-word;line-break:after-white-space" class=""><div style="word-wrap:break-word;line-break:after-white-space" class=""><br class=""><div class=""><span class=""><br class=""><blockquote type="cite" class=""><div class="">On Nov 30, 2017, at 2:48 PM, Jonathan Hull via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_5971727561394076537m_1846945263657774348Apple-interchange-newline"><div class=""><div style="word-wrap:break-word" class="">I would personally go with:<div class=""><br class=""></div><div class=""><span class="m_5971727561394076537m_1846945263657774348Apple-tab-span" style="white-space:pre-wrap">        </span>Int.random //Returns a random Int</div></div></div></blockquote><div class=""><br class=""></div></span><div class="">“Type.random” is so rarely used as to not be worth the addition, IMO. If you really need a random element from the *entire* domain, then I think you should have to manually create the ClosedRange&lt;T&gt; yourself.</div><span class=""><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap:break-word" class=""><div class=""><span class="m_5971727561394076537m_1846945263657774348Apple-tab-span" style="white-space:pre-wrap">        </span>Int.random(in: ClosedRange&lt;Int&gt;) //Works for Comparable types. Gives a result from the closed range. Closed Range is never empty.</div></div></div></blockquote><div class=""><br class=""></div></span><div class="">This is redundant. In order to pick a random element, you’re saying I should have to do “Int.random(0 ..&lt; 10)”? The redundancy here is that I have to specify Int twice: once for the “.random” call, and again for the type of the range. We can do better than that.</div></div></div></div></blockquote></div></div></div></div></blockquote><div class=""><br class=""></div></span><div class="">I don’t see how this is redundant—do you mean that you’d need to write out the type name instead of writing `(0..&lt;10).random()!`? I continue to be of the opinion that picking a random integer/floating-point value/Boolean and picking a random element from a collection are two different operations. Yes, there’s overlap between the two, but they’re different enough that having two ways to choose an integer between 0 and 10 would be fine.</div></div></div></blockquote><div class=""><br class=""></div><div class="">As I wrote elsewhere, if they're sufficiently different enough, then they ought to have distinct names. If they are not, then there ought to be only one of them. I'm no longer sure myself of which one I'd prefer, but in no case should there be two things named "random."</div><div class=""><br class=""></div><div class="">If the proposal to make `IndexDistance == Int` is accepted, then ranges cannot conform to Collection and we encounter some interesting difficulties attempting to index into such a collection to pick a random value.</div></div></div></div></div></blockquote><br class=""></div><div>I'd like to put forth that Gameplay Kit offers a perfectly cromulent model of random number generation and API. Why not take that as a starting point, Swiftify it so it becomes a cross platform solution, and then apply the specific questions of sequences, collections, and indices as a second step? &nbsp;</div><div><br class=""></div><div>I don't support intermingling random functionality with existing core types.</div><div><br class=""></div><div>-- E</div><div><br class=""></div><br class=""></body></html>