> On Nov 17, 2017, at 4:09 PM, Xiaodi Wu via swift-evolution 
> <[email protected]> wrote:
> 
<snip>
> 
> Certainly it's hard to defend Date.random (and yes, it might be useful for a 
> fuzzer, but that's a very niche use case--and in that case the fuzzer should 
> probably also generate invalid/non-existent dates, which surely Date.random 
> should not do). But actually, Int.random followed by % is the much bigger 
> issue and a very good cautionary tale for why T.random is not a good idea. 
> Swift should help users do the correct thing, and getting a random value 
> across the full domain and computing an integer modulus is never the correct 
> thing to do because of modulo bias, yet it's a very common error to make. We 
> are much better off eliminating this API and encouraging use of the correct 
> API, thereby reducing the likelihood of users making this category of error.

+1.

-DW
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to