[swift-evolution] [Proposal] Random Unification

susan.doggie at gmail.com susan.doggie at gmail.com
Tue Sep 26 21:11:38 CDT 2017


First of all, I like this proposal.

For a empty RandomAccessCollection, is it cause a fatal error with calling the random methods?

> Alejandro Alonso via swift-evolution <swift-evolution at swift.org> 於 2017年9月26日 下午12:57 寫道:
> 
> Hello evolution,
> 
> I am very thankful for all the feedback, and I’ve been working on a design that tries to utilize everybody’s ideas. The link to what I have so far is here: https://gist.github.com/Azoy/15f0518df38df9b722d4cb17bafea4c1. Please keep in mind this is just a design, no actual implementation as I would most likely need assistance in doing. The default source for randomness will use the OS’s unseeded CSPRNG. This current setup exposes developers to an API that lets them create their own RandomSources on the fly. I want to make the distinction that any existing or new sources of randomness that conform to UnsafeRandomSource are to be considered non cryptographically secure.
> 
> I would love to get this discussion flowing again, and I would love input on the design. A few things I came across with this design is that some may want to use ranges as an argument for the numeric types, RandomAccessCollection returning an optional when getting a random, and how to incorporate an API that allows distributions. I wanted to get input on how you feel about each of these topics as I’m indifferent about them all. I’m in no way saying this is the design we should go for, but I’m simply providing something I think we should build on or talk about.
> 
> - Alejandro
> 
>> On Sep 8, 2017, 11:52 AM -0500, Alejandro Alonso via swift-evolution <swift-evolution at swift.org>, wrote:
>> Hello swift evolution, I would like to propose a unified approach to `random()` in Swift. I have a simple implementation here https://gist.github.com/Azoy/5d294148c8b97d20b96ee64f434bb4f5. 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.
>> 
>> 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.
>> 
>> I’d like to hear about your ideas on this proposal, or any implementation changes if need be.
>> 
>> - Alejando
>> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170927/d085c020/attachment.html>


More information about the swift-evolution mailing list