Re: [swift-users] [Feature Request] Extend the `defer` statement

2017-10-08 Thread Jun Zhang via swift-users
Yes that's true, but this requires me to set a return value in every `early return` statement. I think this should be done by the compiler instead of me, to make code cleaner and also less error-prone. On Mon, Oct 9, 2017 at 11:24 AM, Slava Pestov wrote: > I think you can

Re: [swift-users] [Feature Request] Extend the `defer` statement

2017-10-08 Thread Slava Pestov via swift-users
I think you can achieve what you want by having the ‘defer’ block capture a mutable local variable. Eg, func doStuff() { var success = false defer { if !success { // do some additional cleanup } } … success = true … return result } > On Oct 8, 2017, at 7:34 PM,

[swift-users] [Feature Request] Extend the `defer` statement

2017-10-08 Thread Jun Zhang via swift-users
Hi dear swift developers, I am kind of new to swift and I don't know if this feature already exists. And if it exists already please tell me how. Thank you very much! The feature is to capturing the return value (maybe input value also) of the function. Here is the demo code: func

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

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

[swift-users] Why does the withUnsafeMutableBufferPointer closure take an inout parameter?

2017-10-08 Thread Martin R via swift-users
I wonder why the closure in the Array method mutating func withUnsafeMutableBufferPointer(_ body: (inout UnsafeMutableBufferPointer) throws -> R) rethrows -> R takes an _inout_ parameter. The closure is called with a pointer to the contiguous array storage, and I fail to imagine an example

Re: [swift-users] How to check the type of a concrete class that inherits from a generic class?

2017-10-08 Thread C. Keith Ray via swift-users
good point - type safety would prevent it from compiling. also, the controllers are subclasses of NSFetchedResultsController but the delegate method takes a different type: NSFetchedResultsController NSManagedObject != NSFetchRequestResult -- C. Keith Ray Senior Software Engineer /

Re: [swift-users] Communicating with dynamically loaded swift library

2017-10-08 Thread Ján Kosa via swift-users
I filed bug report: https://bugs.swift.org/browse/SR-6091 On 8 October 2017 at 20:31, Daniel Dunbar wrote: > Can you file this on bugs.swift.org? We are likely to lose track of it if > it just an email thread > > - Daniel > > On Oct 8, 2017, at 8:27 AM, Ján Kosa

[swift-users] Question about typo fixes on the Swift website.

2017-10-08 Thread Mayur Dhaka via swift-users
Hello, I recently came across a couple of typos in the ‘Contributing’ document on Swift.org . I wanted to know what the preferred place to raise these issues might be? Thanks for your time. — Mayur___ swift-users mailing list

Re: [swift-users] Communicating with dynamically loaded swift library

2017-10-08 Thread Ján Kosa via swift-users
Hey guys, I have been able to create simplest possible setup that exhibits this problem, the protobuf module wasn't necessary. All I import is PluginInterface and I get the error: objc[66212]: Class _TtC15PluginInterface15PluginInterface is implemented in both