Re: [swift-users] Incorrect Fisher-Yates shuffle in example code

2017-12-17 Thread Saagar Jha via swift-users
Saagar Jha > On Dec 17, 2017, at 22:24, Nevin Brackett-Rozinsky via swift-users > wrote: > > …well that was more complicated than I anticipated. > > The “random” function was (Int) -> Int, so when I removed the “IndexDistance > == Int” constraint on “shuffle” I either

Re: [swift-users] Incorrect Fisher-Yates shuffle in example code

2017-12-17 Thread Nevin Brackett-Rozinsky via swift-users
…well that was more complicated than I anticipated. The “random” function was (Int) -> Int, so when I removed the “IndexDistance == Int” constraint on “shuffle” I either had to add several “numericCast” calls or make “random” generic. So I made “random” generic. And also fixed the modulo bias

Re: [swift-users] Compiler fLag to activate SE-0143 (conditional conformance)?

2017-12-17 Thread Slava Pestov via swift-users
> On Dec 14, 2017, at 7:42 PM, Dave Abrahams wrote: > > IMO it makes as much sense to mention the flag in the proposal as it does to > point at a proof-of-concept implementation that accompanies a proposal. > Generally we only accept proposals that “have an

Re: [swift-users] Incorrect Fisher-Yates shuffle in example code

2017-12-17 Thread Nevin Brackett-Rozinsky via swift-users
On Sun, Dec 17, 2017 at 7:37 PM, Dave Abrahams wrote: > > On Dec 16, 2017, at 4:34 PM, Nevin Brackett-Rozinsky via swift-users < > swift-users@swift.org> wrote: > > public extension MutableCollection where Self: RandomAccessCollection, > IndexDistance == Int { > > >

[swift-users] TWISt-shout Newsletter 2017-12-18

2017-12-17 Thread Kenny Leung via swift-users
Hi All. Here is your TWISt-shout Newsletter for the week of 2017-12-11 to 2017-12-17 https://github.com/pepperdog/TWISt-shout/blob/master/2017/TWISt-shout-2017-12-18.md Enjoy! -Kenny

Re: [swift-users] Incorrect Fisher-Yates shuffle in example code

2017-12-17 Thread Dave Abrahams via swift-users
> On Dec 16, 2017, at 4:34 PM, Nevin Brackett-Rozinsky via swift-users > wrote: > > public extension MutableCollection where Self: RandomAccessCollection, > IndexDistance == Int { > IndexDistance == Int is an over-constraint, FWIW. Adding it is generally a mistake.

Re: [swift-users] A problem about interact with C macros

2017-12-17 Thread Geordie Jay via swift-users
Thinking about this a bit more: Imagine you imported another header later that “#undef SITUATION2” and then redefined it with a different value. The fact that SITUATIONALL is an expression and not a value would then produce a different result. For some this would be expected and for others a

Re: [swift-users] A problem about interact with C macros

2017-12-17 Thread Geordie Jay via swift-users
I think this is because the C preprocessor will interpret SITUATIONALL not as a value but as an expression. That means your C code at that spot will be turned into “(SITUATION1 | SITUATION2 | etc)” and not into the result of that expression directly. The clang importer could probably figure this

[swift-users] A problem about interact with C macros

2017-12-17 Thread Li Keqing via swift-users
Here are some macros in C headers such as #define SITUATION1 0x0001 #define SITUATION1 0x0002 #define SITUATION3 0x0004 #define SITUATION4 0x0008 #define SITUATIONALL (SITUATION1 | SITUATION2 | SITUATION3 | SITUATION4) when use these value in swift those lines are okay let value1