Re: [swift-users] Array not Encodable - error at runtime, not compile time?

2017-10-26 Thread Robert Nikander via swift-users
e Element : Decodable. > At the moment, this isn’t possible, so Array is unconditionally Codable and > the failure happens at runtime. This will be a compile-time error in a future > version of Swift. > > — Itai > > On 26 Oct 2017, at 9:47, Robert Nikander via swift-u

[swift-users] Array not Encodable - error at runtime, not compile time?

2017-10-26 Thread Robert Nikander via swift-users
Hi, This error makes perfect sense, but I’m surprised it's a runtime error. I expected it at compile time. Am I doing something wrong? Is this on the type system to-do list? let c = JSONEncoder() struct Foo { … } let fs: [Foo] = [ Foo(...) ] let data = try! c.encode(fs) // Didn’t thin

Re: [swift-users] Can't use unsafe pointer from second thread?

2017-06-18 Thread Robert Nikander via swift-users
mes, use takeRetainedValue > only once at the end.) > >> Le 18 juin 2017 à 9:23, Robert Nikander via swift-users >> mailto:swift-users@swift.org>> a écrit : >> >> Hi, >> >> I’m porting some C to Swift and I need to pass a Swift instance through a

[swift-users] Can't use unsafe pointer from second thread?

2017-06-18 Thread Robert Nikander via swift-users
Hi, I’m porting some C to Swift and I need to pass a Swift instance through a `void *` (ie, UnsafeMutableRawPointer). It works, in one thread, but when a second thread accesses the exact same pointer, it fails with memory errors like EXC_BAD_ACCESS The code below could be pasted into an AppDel

[swift-users] wishing I could cast (sort of) to protocol with associated type

2016-11-02 Thread Robert Nikander via swift-users
Hi, In the following code, I want to test if x is a `SpecialController`. If it is, I want to get the `currentValue` as a `SpecialValue`. How do you do this? If not with a cast, then some other technique. I understand the error, and that SpecialController by itself is not a simple type to cast

[swift-users] NSData vs Data write to string differently?

2016-09-22 Thread Robert Nikander via swift-users
Hi, I’ve run into a problem when updating to new Swift in Xcode 8. There was some NSData in a string like this: “ … \(data) … “ It changed to type `Data`, and the string went from hexadecimal bytes to writing “20 bytes”. I’m doing a quick bug fix app release now. I can’t remember if X

[swift-users] plugins, verifiable code?

2016-05-25 Thread Robert Nikander via swift-users
Hi, I’m thinking about creating an OS X app with dynamically loaded plugins. I hear that it’s safest to load plugins in a separate process, so they can’t crash the host program. I haven’t tried this yet, so I’m not sure exactly how it will work. But it got me wondering… has there been any discu