Re: [swift-users] [swift-evolution] Best way to handle escaping function that might throw

2017-01-10 Thread T.J. Usiyan via swift-users
I suggest using an enum to represent success and failure. It's usually referred to as `Result`. It might seem weird for the closure that you presented as an example, since it would be Result, but it properly captures the possibility of having thrown. ``` swift enum UselessError : Swift.Error {

Re: [swift-users] Exclamation mark's in swift parameter listings?

2017-01-10 Thread Rien via swift-users
I stand corrected. I do/did think that there is a difference in the way it handles pointers optionals and other optionals, but I now realise that even that could not be the case. So please ignore the last line in my previous post. The rest still stand ;-) Regards, Rien Site: http://balancingr

Re: [swift-users] Exclamation mark's in swift parameter listings?

2017-01-10 Thread Joe Groff via swift-users
> On Jan 9, 2017, at 11:19 PM, Rien via swift-users > wrote: > > It means that a call to that function with an optional will unwrap the > optional before it is used. > > That is quite neat when dealing with C-API’s because often you will receive a > pointer from a C-function which is optiona

Re: [swift-users] Zero cost abstraction 2D Iterator (equivalent to two nested for loops) impossible?

2017-01-10 Thread Step Christopher via swift-users
Perhaps the optimizer unrolls the inner loop, and thus can skip safety checks. Naively, seems trickier to do for the iterator. > El ene. 4, 2017, a las 9:10 PM, Jens Persson via swift-users > escribió: > > I noticed disabling safety checks made the custom Iterator as fast as the two > nested

Re: [swift-users] make a static/class method return type be the subclass it is called with

2017-01-10 Thread Slava Pestov via swift-users
> On Jan 9, 2017, at 11:59 PM, Pierre Monod-Broca via swift-users > wrote: > > Hi again, > > You might want to look at Self requirement in protocols for exemple: > protocol P { > func items(/*...*/) -> [Self] > } > class C: P { > func items(/*...*/) -> [C] { >... > } > } FWIW, this req

Re: [swift-users] make a static/class method return type be the subclass it is called with

2017-01-10 Thread Pierre Monod-Broca via swift-users
Hi again, You might want to look at Self requirement in protocols for exemple: protocol P { func items(/*...*/) -> [Self] } class C: P { func items(/*...*/) -> [C] { ... } } However it might not always work as you expect. I can't say which is the better. Using associated type might be