[swift-users] Fwd: Workaround for generics not currently supporting conditional conformance to a protocol

2016-11-15 Thread Howard Lovatt via swift-users
@Dave, How do I write that though. I can't write: extension Array: Equatable { static func ==(lhs: Array, rhs: Array) -> Bool { let size = lhs.count precondition(rhs.count == size, "The arrays must be the same length") for i in 0 ..< size {

[swift-users] Workaround for generics not currently supporting conditional conformance to a protocol

2016-11-15 Thread Tim Vermeulen via swift-users
Not really, unfortunately. The standard library is littered with types because of exactly this (e.g. `MutableRangeReplaceableRandomAccessSlice`). Conditional conformance can’t come fast enough! > Hi All, > > Does anyone have a good workaround for generics not currently supporting > conditional

Re: [swift-users] Attempting to call default protocol implementation crashes Playground

2016-11-15 Thread Игорь Никитин via swift-users
And, as I know, it's not possible to call protocol's implementation in that case > 16 нояб. 2016 г., в 4:29, Rick Mann via swift-users > написал(а): > > Okay. I coudln't find official documentation on this, and I don't currently > need to do this, but wanted to fully understand it. > >> On No

Re: [swift-users] Attempting to call default protocol implementation crashes Playground

2016-11-15 Thread Игорь Никитин via swift-users
And, as I know, it's not possible to call protocol's implementation in that case > 16 нояб. 2016 г., в 9:09, Игорь Никитин via swift-users > написал(а): > > Right, it’s a recursion, because this > > (self as FooPro).fooFunc() > > Will call FooClass’s method implementation > > You can read

Re: [swift-users] Attempting to call default protocol implementation crashes Playground

2016-11-15 Thread Игорь Никитин via swift-users
Right, it’s a recursion, because this (self as FooPro).fooFunc() Will call FooClass’s method implementation You can read more about dispatch rules here: https://medium.com/ios-os-x-development/swift-protocol-extension-method-dispatch-6a6bf270ba94#.hkh1rc56p

[swift-users] Workaround for generics not currently supporting conditional conformance to a protocol

2016-11-15 Thread Howard Lovatt via swift-users
Hi All, Does anyone have a good workaround for generics not currently supporting conditional conformance to a protocol. As stated in the Generics Manifesto something like this would be nice: extension Array: Equatable where Element: Equatable { static func ==(lhs: Array, rhs: Array) ->

Re: [swift-users] Attempting to call default protocol implementation crashes Playground

2016-11-15 Thread Rick Mann via swift-users
Okay. I coudln't find official documentation on this, and I don't currently need to do this, but wanted to fully understand it. > On Nov 15, 2016, at 17:27 , zh ao wrote: > > 'Default' implementation in protocol extension is used as fail safe. You > should not consider it like something super

Re: [swift-users] Attempting to call default protocol implementation crashes Playground

2016-11-15 Thread zh ao via swift-users
'Default' implementation in protocol extension is used as fail safe. You should not consider it like something super class does. If you want it that way, use class inheritance instead. Zhaoxin Get Outlook for iOS _ From: Rick Mann via swift-users Sen

Re: [swift-users] Attempting to call default protocol implementation crashes Playground

2016-11-15 Thread Rick Mann via swift-users
Well, this is a standard protocol default implementation. I was experimenting to see if it was possible to call the default implementation after providing a concrete implementation. > On Nov 15, 2016, at 14:47 , Dan Loewenherz wrote: > > What are you trying to accomplish here, more concretely?

Re: [swift-users] Attempting to call default protocol implementation crashes Playground

2016-11-15 Thread Dan Loewenherz via swift-users
What are you trying to accomplish here, more concretely? My first thought is that you shouldn't implement the same function in both a protocol extension and a conforming class. Why not just give them different names and call the function from within the extension instead of from the class? E.g. p

[swift-users] Attempting to call default protocol implementation crashes Playground

2016-11-15 Thread Rick Mann via swift-users
The following gives Xcode 8.1 a very hard time. Eventually I get a Bad Access on the last line. I'm guessing it's a recursive call. Is there any way to call the default implementation from a "real" implementation? protocol FooPro { func fooFunc() } extension FooPro { func

Re: [swift-users] Reflection in Swift 3?

2016-11-15 Thread Rick Mann via swift-users
> On Nov 15, 2016, at 05:24 , Jeremy Pereira > wrote: > > >> On 15 Nov 2016, at 10:33, Rick Mann wrote: >> >> Well, that's not really any different than a switch statement, in that it >> has to be maintained. > > Yes, but I would argue that it is a good thing because you need to do some >

[swift-users] Planned Outage - Nov 15th 2016 at 11pm PST

2016-11-15 Thread mishal_shah via swift-users
Planned Outage: When: Nov 15th 2016 at 11pm PST Duration: 1-2hrs Services affected: - Swift Website: swift.org - Swift CI: ci.swift.org - Swift Bugs: bugs.swift.org - Swift Mail: lists.swift.org Tha

Re: [swift-users] Reflection in Swift 3?

2016-11-15 Thread Jeremy Pereira via swift-users
> On 15 Nov 2016, at 10:33, Rick Mann wrote: > > Well, that's not really any different than a switch statement, in that it has > to be maintained. Yes, but I would argue that it is a good thing because you need to do some validation before you instantiate the class anyway. Furthermore, it gi

Re: [swift-users] Reflection in Swift 3?

2016-11-15 Thread Rick Mann via swift-users
Well, that's not really any different than a switch statement, in that it has to be maintained. > On Nov 15, 2016, at 01:50 , Jeremy Pereira > wrote: > > Perhaps I’m missing something here, but why not use a map? > >let factoryMap = [ String : () -> SuperClassOrCommonProtocol ] = [ > “My

Re: [swift-users] Reflection in Swift 3?

2016-11-15 Thread Jeremy Pereira via swift-users
Perhaps I’m missing something here, but why not use a map? let factoryMap = [ String : () -> SuperClassOrCommonProtocol ] = [ “MySubClass" : { return MySubClass() }, … ] … guard let factoryMethod = factoryMap[theClassName] else { /* error */ } return factoryMethod() This is an

Re: [swift-users] Overload Resolution of Binary Operators

2016-11-15 Thread Toni Suter via swift-users
@David If you would split up the statement like this... let x = 0 *** 4 let result = x +++ 0 ... the compiler would report an ambiguity error, because both overloads of *** are valid and of equivalent priority. You could do something like this though: let x: Int = 0 *** 4// picks f2 let res