<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
</head>
<body>
<div name="messageBodySection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;">
I wrote up a quick and dirty example displaying Randomizable in action working alongside Strideable&nbsp;<a href="https://gist.github.com/Azoy/30d2554d11a3fb8f770e3b310fb47aca">https://gist.github.com/Azoy/30d2554d11a3fb8f770e3b310fb47aca</a>&nbsp;. This example uses
 the 32 bit Unix timestamp to determine a Date’s range (0 … UInt32.max). Color’s range would obviously be 0 … 0xFFFFFF. As you can see from this example, Randomizable has the potential to provide massive functionality to types that are able to conform to it.
 Rust also implements a trait called Rand that achieves the same here&nbsp;<a href="https://doc.rust-lang.org/rand/rand/trait.Rand.html">https://doc.rust-lang.org/rand/rand/trait.Rand.html</a>&nbsp;.&nbsp;</div>
<div name="messageSignatureSection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;">
<br>
- Alejandro</div>
<div name="messageReplySection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;">
<br>
On Nov 15, 2017, 11:43 AM -0600, Nate Cook &lt;natecook@apple.com&gt;, wrote:<br>
<blockquote type="cite" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #1abc9c;">
<div>
<blockquote type="cite" class="" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #e67e22;">
<div class="">On Nov 12, 2017, at 7:47 PM, Alejandro Alonso &lt;<a href="mailto:aalonso128@outlook.com" class="">aalonso128@outlook.com</a>&gt; wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="">
<div name="messageBodySection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;" class="">
Sorry I’ve been gone for a while, I had to do a lot of traveling.
<div class=""><br class="">
</div>
<div class="">1. Initially I made this thinking that developers had the power to determine their own lower bound. The current implementation uses the integer’s min value as a lower bound. If it makes sense to only allow unsigned integers from an RNG, then I’m
 perfectly fine with. I do disagree when you say that it should only generate UInt32s. The current approach allows, lets say mt19337 and mt19337-64, to be used within one generator. So if you wanted a UInt32, mt19337 would be used, and if you asked for a UInt64,
 mt19337-64 would be used.</div>
<div class=""><br class="">
</div>
<div class="">2. The Randomizable protocol isn’t always used with integers. Think Date.random or Color.random. These types of values are difficult to express with ranges. Randomizable solves this issue.</div>
</div>
</div>
</div>
</blockquote>
<div><br class="">
</div>
<div>I don’t think these examples explain how the <font face="Menlo" class="">Randomizable</font> protocol is useful. As currently proposed, types that are
<font face="Menlo" class="">Randomizable</font> can provide a random value, but the details of that are left up to the type, and vary widely. When you use
<font face="Menlo" class="">.random</font> on an integer type, you get any value between
<font face="Menlo" class="">.min</font> and <font face="Menlo" class="">.max</font>, but on a floating-point type, it’s a value between 0.0 and 1.0. What would the range be when you use
<font face="Menlo" class="">Date.random</font>? What about <font face="Menlo" class="">
Color.random</font>?</div>
<div><br class="">
</div>
<div>Here’s an implementation using the <font face="Menlo" class="">Randomizable</font> protocol as a constraint:</div>
<div><br class="">
</div>
<div><font face="Menlo" class="">&nbsp; &nbsp; extension Array where Element: Randomizable {</font></div>
<div><span style="font-family: Menlo;" class="">&nbsp; &nbsp;</span><span style="font-family: Menlo;" class="">&nbsp;</span><font face="Menlo" class="">&nbsp; &nbsp; init(randomElements: Int) {</font></div>
<div><font face="Menlo" class="">&nbsp; &nbsp;&nbsp;</font><span style="font-family: Menlo;" class="">&nbsp; &nbsp;</span><span style="font-family: Menlo;" class="">&nbsp;</span><span style="font-family: Menlo;" class="">&nbsp; &nbsp; self = (0..&lt;randomElements).map({ _ in Element.random })</span></div>
<div><span style="font-family: Menlo;" class="">&nbsp; &nbsp;</span><span style="font-family: Menlo;" class="">&nbsp;</span><font face="Menlo" class="">&nbsp; &nbsp; }</font></div>
<div><span style="font-family: Menlo;" class="">&nbsp; &nbsp;</span><span style="font-family: Menlo;" class="">&nbsp;</span><font face="Menlo" class="">}</font></div>
<div><br class="">
</div>
<div>Is this useful? Note that there’s no way to constrain these random values to be in a particular range or any other criteria—they’re only going to be random values in whatever the range is that a specific types supplies.</div>
<div><br class="">
</div>
<div>The point I’m trying to make is that although all these types can have random values generated, their similarity is mostly coincidental. As long as we provide good ways of generating random values at the appropriate level, we don’t need the Randomizable
 protocol. (To me, the appropriate extension points are FixedWidthInteger, BinaryFloatingPoint, and Bool.) Without Randomizable, we can still write things like this, which are the kinds of functionality we want to add anyway:</div>
<div><br class="">
</div>
<div>
<div><span style="font-family: Menlo;" class="">&nbsp; &nbsp;</span><span style="font-family: Menlo;" class="">&nbsp;</span><font face="Menlo" class="">extension Array where Element: FixedWidthInteger {</font></div>
<div><font face="Menlo" class="">&nbsp; &nbsp;&nbsp;</font><span style="font-family: Menlo;" class="">&nbsp; &nbsp;</span><span style="font-family: Menlo;" class="">&nbsp;</span><span style="font-family: Menlo;" class="">init(randomElements: Int, in bounds: Range&lt;Element&gt;) {</span></div>
<div><span style="font-family: Menlo;" class="">&nbsp; &nbsp;</span><span style="font-family: Menlo;" class="">&nbsp;</span><font face="Menlo" class="">&nbsp; &nbsp; &nbsp; &nbsp; self = (0..&lt;randomElements).map({ _ in bounds.random })</font></div>
<div><font face="Menlo" class="">&nbsp; &nbsp;&nbsp;</font><span style="font-family: Menlo;" class="">&nbsp; &nbsp;</span><span style="font-family: Menlo;" class="">&nbsp;</span><span style="font-family: Menlo;" class="">}</span></div>
<div><span style="font-family: Menlo;" class="">&nbsp; &nbsp;</span><span style="font-family: Menlo;" class="">&nbsp;</span><font face="Menlo" class="">}</font></div>
</div>
<div><br class="">
</div>
<div>-Nate</div>
<div><br class="">
</div>
<blockquote type="cite" class="" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #e67e22;">
<div class="">
<div class="">
<div name="messageBodySection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;" class="">
<div class="">3. I’ve made the adjustment necessary for this.</div>
<div class=""><br class="">
</div>
<div class="">4. So while I can see your point for this, it would break the consistency with Randomizable’s random property. You could argue that we could make this property a function itself, but I think most will agree that Int.random is a cleaner api than
 Int.random().&nbsp;</div>
<div class=""><br class="">
</div>
<div class="">5. I’ve made the adjustment necessary for this.</div>
<div class=""><br class="">
</div>
<div class="">6. I actually forgot to implement the random api for the ranges where Bound: BinaryFloatingPoint. While implementing this, I realized these would never fail and would always return a non-optional. So, I decided making the other Countable ranges
 non-optional. (0 ..&lt; 10).random would return a non-optional, (0.0 ..&lt; 10.0).random would return a non-optional, and Array(0 ..&lt; 10).random would return an optional. I can agree that something like (0 ..&lt; 10).random is hard to discover, so I added Int.random(in:
 0 ..&lt; 10) (along with BinaryFloatingPoint). However, these are not requirements of Randomizable. I think these methods would benefit more if they were extension methods:</div>
<div class=""><br class="">
</div>
<div class="">extension Randomizable where Self: FixedWidthInteger, Self.Stride: SignedInteger {</div>
<div class=""> public static func random(</div>
<div class="">  in range: Countable{Closed}Range,</div>
<div class="">  using generator: RandomNumberGenerator</div>
<div class=""> ) -&gt; Self {</div>
<div class="">  return range.random(using: generator)</div>
<div class=""> }<br class="">
</div>
<div class="">}</div>
<div class=""><br class="">
</div>
<div class="">extension Randomizable where Self: BinaryFloatingPointer {</div>
<div class=""> public static func random(<br class="">
</div>
<div class="">  in range: {Closed}Range,</div>
<div class="">  using generator: RandomNumberGenerator</div>
<div class=""> ) -&gt; Self {</div>
<div class="">  return range.random</div>
<div class=""> }<br class="">
</div>
<div class="">}</div>
<div class=""><br class="">
</div>
<div class="">I think external types that wish to do something similar, like Data.random(bytes: 128), could extend Randomizable with their own custom needs. The stdlib would at this point provide all the features needed to make this happen very simply for something
 like Data.random(bytes: 128).</div>
</div>
<div name="messageSignatureSection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;" class="">
<br class="">
- Alejandro</div>
<div name="messageReplySection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;" class="">
<br class="">
On Nov 5, 2017, 10:44 PM -0600, Nate Cook &lt;<a href="mailto:natecook@apple.com" class="">natecook@apple.com</a>&gt;, wrote:<br class="">
<blockquote type="cite" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #3498db;" class="">
Thanks for continuing to push this forward, Alejandro! I’m excited about the potential of having access to these APIs as part of the standard library. Here are a few comments on some different parts of the proposal:
<div class=""><br class="">
</div>
<div class="">1) For your&nbsp;<font face="Menlo" class="">RandomGenerator</font> protocol, I’m not totally clear on the semantics of the
<font face="Menlo" class="">next(_:)</font> and <font face="Menlo" class="">next(_:upperBound:)</font> methods. Do they both have zero as their lower bound, for example? I’m not sure it makes sense to have signed integers generated directly by an RNG—perhaps
<font face="Menlo" class="">T: FixedWidthInteger &amp; UnsignedInteger</font> would be a more useful constraint. (Does it even need to be generic? What if RNGs just generate
<font face="Menlo" class="">UInt32</font>s?)</div>
<div class=""><br class="">
</div>
<div class="">2) Can you say more about the purpose of the <font face="Menlo" class="">
Randomizable</font> protocol? How would we use that protocol in useful ways that we wouldn’t get from being able to select random values from ranges (half-open and closed) of
<font face="Menlo" class="">FixedWidthInteger</font> / <font face="Menlo" class="">
BinaryFloatingPoint</font>? My experience has been that a full-width random value is rarely what a user needs.</div>
<div class=""><br class="">
</div>
<div class="">3) I agree with Xiaodi that <font face="Menlo" class="">Random</font> should probably be a struct with a single shared instance, but I don’t think it should be internal. Hiding that shared RNG would make it hard for non-stdlib additions to have
 the same usage, as they would need to have completely separate implementations for the “default” and custom RNG versions.</div>
<div class=""><br class="">
</div>
<div class="">4) I would also still suggest that the simplest version of <font face="Menlo" class="">
random</font>&nbsp;(that you use to get a value from a range or an element from a collection) should be a function, not a property. Collection properties like
<font face="Menlo" class="">first</font>, <font face="Menlo" class="">last</font>, and
<font face="Menlo" class="">count</font> all represent facts that already exist about a collection, and don’t change unless the collection itself changes. Choosing a random element, on the other hand, is clearly going to be freshly performed on each call. In
 addition, with the notable exception of <font face="Menlo" class="">count</font>, we try to ensure O(1) performance for properties, while
<font face="Menlo" class="">random</font> will be O(n) except in random-access collections. Finally, if it is a method, we can unify the two versions by providing a single method with the shared RNG as the default parameter.</div>
<div class=""><br class="">
</div>
<div class="">5) To match the <font face="Menlo" class="">sorted()</font> method,
<font face="Menlo" class="">shuffled()</font> should be on <font face="Menlo" class="">
Sequence</font> instead of <font face="Menlo" class="">Collection</font>. I don’t think either
<font face="Menlo" class="">shuffled()</font> or <font face="Menlo" class="">shuffle()</font> needs to be a protocol requirement, since there isn’t really any kind of customization necessary for different kinds of collections. Like the sorting algorithms, both
 could be regular extension methods.
<div class="">
<div class=""><br class="">
</div>
<div class="">6) I don’t know whether or not a consensus has formed around the correct spelling of the APIs for generating random values. From the proposal it looks like the preferred ways of getting a random value in a range would be to use the random property
 (or method) on a range or closed range:</div>
<div class=""><br class="">
</div>
<div class=""><font face="Menlo" class="">&nbsp; &nbsp; (0..&lt;10).random &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// 7</font></div>
<div class=""><font face="Menlo" class="">&nbsp; &nbsp; (0.0&nbsp;... 5.0).random &nbsp; &nbsp; // 4.112312</font></div>
<div class=""><br class="">
</div>
<div class="">If that’s the goal, and we don’t want those values to be optional, we’ll need an implementation of random for floating-point ranges and an overload for fixed-width integer ranges. That said, I don’t think that style is as discoverable as having
 static methods or initializers available on the different types:</div>
<div class=""><br class="">
</div>
<div class=""><span style="font-family: Menlo;" class="">&nbsp; &nbsp; Int.random(in: 0..&lt;10)</span></div>
<div class=""><span style="font-family: Menlo;" class="">&nbsp; &nbsp; Double.random(in: 0.0 ... 5.0)</span></div>
<div class=""><font face="Menlo" class="">&nbsp; &nbsp; // or maybe</font></div>
<div class=""><font face="Menlo" class="">&nbsp; &nbsp; Int(randomIn: 0..&lt;10)</font></div>
<div class=""><font face="Menlo" class="">&nbsp; &nbsp; Double(randomIn: 0.0 ... 5.0)</font></div>
<div class=""><br class="">
</div>
<div class="">(My only quibble with the initializer approach is that <font face="Menlo" class="">
Bool</font> would be awkward.)</div>
<div class=""><br class="">
</div>
<div class="">In addition, this alternative approach could make creating random values more consistent with types that don’t work well in ranges:</div>
<div class=""><br class="">
</div>
<div class="">
<div class=""><span style="font-family: Menlo;" class="">&nbsp; &nbsp; Data.random(bytes: 128)</span></div>
<div class=""><span style="font-family: Menlo;" class="">&nbsp; &nbsp; Color.random(r: 0...0, g: 0...1, b: 0...1, a: 1...1)</span></div>
<div class=""><br class="">
</div>
<div class=""><span style="font-family: Menlo;" class="">————</span></div>
<div class=""><span style="font-family: Menlo;" class=""><br class="">
</span></div>
</div>
<div class="">Thanks again!</div>
<div class="">Nate</div>
<div class=""><br class="">
<blockquote type="cite" class="" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #d35400;">
<div class="">On Nov 5, 2017, at 6:33 PM, Alejandro Alonso 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 class="">
<div name="messageBodySection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;" class="">
<a href="https://github.com/apple/swift-evolution/pull/760" class="">https://github.com/apple/swift-evolution/pull/760</a>&nbsp;is the current API and proposed solution.</div>
<div name="messageSignatureSection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;" class="">
<br class="">
- Alejandro</div>
<div name="messageReplySection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;" class="">
<br class="">
On Nov 5, 2017, 6:18 PM -0600, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" class="">xiaodi.wu@gmail.com</a>&gt;, wrote:<br class="">
<blockquote type="cite" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #34495e;" class="">
<div dir="ltr" class="">
<div class="">My comments are directed to the &quot;more up-to-date&quot; document that you just linked to in your reply to Jon. Is that one outdated? If so, can you send a link to the updated proposal and implementation for which you're soliciting feedback?</div>
<br class="">
<div class="gmail_extra"><br class="">
<div class="gmail_quote">On Sun, Nov 5, 2017 at 6:12 PM, Alejandro Alonso <span dir="ltr" class="">
&lt;<a href="mailto:aalonso128@outlook.com" target="_blank" class="">aalonso128@outlook.com</a>&gt;</span> wrote:<br class="">
<blockquote class="gmail_quote" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #2ecc71;">
<div class="">
<div name="messageBodySection" style="font-size:14px;font-family:-apple-system,BlinkMacSystemFont,sans-serif" class="">
The proposal and implementation have the current updated API. The link I sent Jon was the one I brought up a few weeks ago which is outdated now. The proposal answers all of your questions. As for `.random` being a function, some would argue that it behaves
 in the same way as `.first` and `.last` which are properties.</div>
<div class="HOEnZb"><font color="#888888" class=""></font>
<div name="messageSignatureSection" style="font-size:14px;font-family:-apple-system,BlinkMacSystemFont,sans-serif" class="">
<font color="#888888" class=""><br class="">
- Alejandro</font></div>
</div>
<div class="">
<div class="h5">
<div name="messageReplySection" style="font-size:14px;font-family:-apple-system,BlinkMacSystemFont,sans-serif" class="">
<br class="">
On Nov 5, 2017, 6:07 PM -0600, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank" class="">xiaodi.wu@gmail.com</a>&gt;, wrote:<br class="">
<blockquote type="cite" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #9b59b6;" class="">
<div dir="ltr" class="">A few quick thoughts:
<div class=""><br class="">
</div>
<div class="">I know that there's been some discussion that `(1...10).random` is the best spelling, but I'd like to push back on that suggestion. When I want a random number, I tend to think of the type I want first (&quot;I want a random integer&quot;) and then a range
 (&quot;I want a random integer between a and b&quot;), not the other way around. My intuition is that `Int.random(in:)` will be more discoverable, both on that basis and because it is more similar to other languages' syntax (`Math.random` in JavaScript and `randint`
 in NumPy,<br class="">
for example). It also has the advantage that the type is explicit, which I think is particularly useful in this case because the value itself is, well, random.</div>
<div class=""><br class="">
</div>
<div class="">I would also argue that, `random` is most appropriately a method and not a property; there's no hard and fast rule for this, but the fact that the result is stochastic suggests (to me) that it's not a &quot;property&quot; of the range (or, for that matter,
 of the type).</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">I would reiterate here my qualms about `Source` being the term used for a generator. These types are not a _source_ of entropy but rather a _consumer_ of entropy.</div>
</div>
<div class=""><br class="">
</div>
<div class="">`UnsafeRandomSource` needs to be renamed; &quot;unsafe&quot; has a specific meaning in Swift--that is, memory safety, and this is not it. Moreover, it's questionable whether this protocol is useful in any sense. What useful generic algorithms can one write
 with such a protocol?</div>
<div class=""><br class="">
</div>
<div class="">`XoroshiroRandom` cannot be seeded by any `Numeric` value; depending on the specific algorithm it needs a seed of a specific bit width. If you default the shared instance to being seeded with an `Int` then you will have to have distinct implementations
 for 32-bit and 64-bit platforms. This is unadvisable. On that note, your `UnsafeRandomSource` needs to have an associated type and not a generic `&lt;T : Numeric&gt;` for the seed.<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">The default random number generator should be cryptographically secure; however, it's not clear to me that it should be device random.</div>
<div class=""><br class="">
</div>
<div class="">I agree with others that alternative random number generators other than the default RNG (and, if not default, possibly also the device RNG) should be accommodated by the protocol hierarchy but not necessarily supplied in the stdlib.</div>
<div class=""><br class="">
</div>
<div class="">The term `Randomizable` means something specific which is not how it's used in your proposed protocol.&nbsp;</div>
<div class=""><br class="">
</div>
<div class="">There's still the open question, not answered, about how requesting an instance of the hardware RNG behaves when there's insufficient or no entropy. Does it return nil, throw, trap, or wait? The proposed API does not clarify this point, although
 based on the method signature it cannot return nil or throw. Trapping might be acceptable but I'd be interested to hear your take as to why it is preferable.</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="gmail_extra">
<div class="gmail_quote">On Sun, Nov 5, 2017 at 4:43 PM, Alejandro Alonso 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="">
<blockquote class="gmail_quote" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #e74c3c;">
<div class="">
<div name="messageBodySection" style="font-size:14px;font-family:-apple-system,BlinkMacSystemFont,sans-serif" class="">
For the proof of concept, I had accidentally deleted that one. I have a more up to date one which was discussed a few weeks later.&nbsp;<a href="https://gist.github.com/Azoy/15f0518df38df9b722d4cb17bafea4c1" target="_blank" class="">https://gist.github.com<wbr class="">/Azoy/15f0518df38df9b722d4cb17<wbr class="">bafea4c1</a></div>
<div name="messageSignatureSection" style="font-size:14px;font-family:-apple-system,BlinkMacSystemFont,sans-serif" class="">
<br class="">
- Alejandro</div>
<div class="">
<div class="m_1947579187318224822gmail-h5">
<div name="messageReplySection" style="font-size:14px;font-family:-apple-system,BlinkMacSystemFont,sans-serif" class="">
<br class="">
On Nov 5, 2017, 4:37 PM -0600, Jonathan Hull &lt;<a href="mailto:jhull@gbis.com" target="_blank" class="">jhull@gbis.com</a>&gt;, wrote:<br class="">
<blockquote type="cite" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #1abc9c;" class="">
Is there a link to the writeup?&nbsp; The one in the quote 404s.
<div class=""><br class="">
</div>
<div class="">Thanks,</div>
<div class="">Jon</div>
<div class=""><br class="">
<div class="">
<blockquote type="cite" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #e67e22;" class="">
<div class="">On Nov 5, 2017, at 2:10 PM, Alejandro Alonso 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_1947579187318224822gmail-m_3739135728595962658Apple-interchange-newline">
<div class="">
<div class="">
<div name="messageBodySection" style="font-size:14px;font-family:-apple-system,BlinkMacSystemFont,sans-serif" class="">
Hello once again Swift evolution community. I have taken the time to write up the proposal for this thread, and have provided an implementation for it as well. I hope to once again get good feedback on the overall proposal.</div>
<div name="messageSignatureSection" style="font-size:14px;font-family:-apple-system,BlinkMacSystemFont,sans-serif" class="">
<br class="">
- Alejandro</div>
<div name="messageReplySection" style="font-size:14px;font-family:-apple-system,BlinkMacSystemFont,sans-serif" class="">
<br class="">
On Sep 8, 2017, 11:52 AM -0500, Alejandro Alonso via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;, wrote:<br class="">
<blockquote type="cite" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #3498db;" class="">
<div name="messageBodySection" style="font-size:14px;font-family:-apple-system,BlinkMacSystemFont,sans-serif" class="">
Hello swift evolution, I would like to propose a unified approach to `random()` in Swift. I have a simple implementation here&nbsp;<a href="https://gist.github.com/Azoy/5d294148c8b97d20b96ee64f434bb4f5" target="_blank" class="">https://gist.github.com/A<wbr class="">zoy/5d294148c8b97d20b96ee64f43<wbr class="">4bb4f5</a>.
 This implementation is a simple wrapper over existing random functions so existing code bases will not be affected. Also, this approach introduces a new random feature for Linux users that give them access to upper bounds, as well as a lower bound for both
 Glibc and Darwin users. This change would be implemented within Foundation.
<div class=""><br class="">
</div>
<div class="">I believe this simple change could have a very positive impact on new developers learning Swift and experienced developers being able to write single random declarations.</div>
<div class=""><br class="">
</div>
<div class="">I’d like to hear about your ideas on this proposal, or any implementation changes if need be.</div>
<div class=""><br class="">
</div>
<div class="">- Alejando</div>
</div>
<div name="messageReplySection" style="font-size:14px;font-family:-apple-system,BlinkMacSystemFont,sans-serif" class="">
<br class="">
<div class=""></div>
</div>
</blockquote>
</div>
</div>
______________________________<wbr class="">_________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/mailma<wbr class="">n/listinfo/swift-evolution</a><br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
</blockquote>
</div>
</div>
</div>
</div>
<br class="">
______________________________<wbr class="">_________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailma<wbr class="">n/listinfo/swift-evolution</a><br class="">
<br class="">
</blockquote>
</div>
<br class="">
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</blockquote>
</div>
</div>
_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</blockquote>
</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</blockquote>
</div>
</body>
</html>