[swift-users] TWISt-shout Newsletter 2017-09-25

2017-09-24 Thread Kenny Leung via swift-users
Hi All.

Here is your TWISt-shout Newsletter for the week of 2017-09-18 to 2017-09-24

https://github.com/pepperdog/TWISt-shout/blob/master/2017/TWISt-shout-2017-09-25.md
 


Enjoy!

-Kenny


___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] UnsafeMutableRawPointer to UnsafeMutablePointer: EXC_BAD_ACCESS on pointee

2017-09-24 Thread Guillaume Lessard via swift-users
[re-sending to the list, and elaborating]

You are making the runtime use the first word of the referent as if it were the 
reference.

The lowercase-c variable is a reference. rawPointer contains the same value, 
and points to the beginning of the object data. Your typecasting is telling the 
runtime that pointer.pointee is a *reference*, but ‘pointer’ points to object 
data. The print statement attempts to dereference data that is not a pointer at 
all.

Consider this:

let badThingToDo = rawPointer.assumingMemoryBound(to: Int.self)[2] // contains 
42

The first word at rawPointer is type data, the second has reference counts (or 
the side table pointer), the third has the first word of instance data.

Note that c is alive, and Unmanaged’s implementation is fine (we wouldn’t have 
made it this far if it weren’t).

Guillaume Lessard


___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] Type inference issue with map and filter chained

2017-09-24 Thread Trevör ANNE DENISE via swift-users
Hello everyone, I found this on StackOverflow : 
https://stackoverflow.com/questions/46381752/swift-4-methods-chaining/ 


Is this a bug of Swift 4 or is this normal ? I don't understand why the problem 
only happens when methods are chained !

Thank you

Trevör___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users