Re: [swift-users] Weird protocol behaviour.

2016-12-22 Thread Dave Abrahams via swift-users
on Thu Dec 22 2016, Mikhail Seriukov wrote: > Hello community! I' wondering if somebody can explain this to me. > Please take look at the snippet. > > protocol P {} > struct X:P {} > > func foo(_ x:A) {} > > func bar() { > //let x = X() // this compiles > let x = X() as P // this does no

Re: [swift-users] Weird protocol behaviour.

2016-12-22 Thread Guillaume Lessard via swift-users
The function foo(x: A){} requires a type which conforms to protocol P. An existential of protocol P does not actually conform to protocol P. It’s always been a limitation in Swift: https://bugs.swift.org/browse/SR-55 If the function’s signature were foo(x: P){}, it would work. Howard’s example

Re: [swift-users] Weird protocol behaviour.

2016-12-22 Thread Howard Lovatt via swift-users
The following variation works: protocol P {} class P1:P {} class X:P1 {} func foo(_ x:A) {} func bar() { //let x = X() // this compiles let x = X() as P1 // this does not compile. Why? foo(x) } Which adds credence to the bug theory. Note two changes: 1. two levels of inhe

[swift-users] Possible bug in Swift REPL autocompletion?

2016-12-22 Thread Eugenio Baglieri via swift-users
Good evening, i was playing with swift REPL. I imported Darwin and using c functions. I noted that autocompletion is unusable if the last character is a parenthesis “(“. The autocompletion seems to not get account of the already written function name, and after parenthesis shows as possible co

[swift-users] How do I use Xcode for a C library wrapped in Swift

2016-12-22 Thread Dave Yost via swift-users
I just posted this on StackOverflow . Insights most welcome. I'm trying to create an Xcode workspace that contains projects that make: A bird dynamic library built from C source A Cbird Swift module

Re: [swift-users] Weird protocol behaviour.

2016-12-22 Thread Kevin Nattinger via swift-users
I recall seeing a request on the -evolution list for something like `T := X` to indicate it could be X itself or anything inheriting / implementing it, so it’s certainly known behavior, if not desired. IMO it’s a bug and `:` should be fixed to include the root type, whether or not that requires

Re: [swift-users] Weird protocol behaviour.

2016-12-22 Thread Howard Lovatt via swift-users
I suspect a compiler bug since A is a P. The equivalent in Java works: interface P {} class X implements P {} void foo(A x) {} void bar() { final P x = new X(); foo(x); } -- Howard. > On 23 Dec 2016, at 3:19 am, Rien via swift-users > wrote: > > IMO the error message says it all

[swift-users] Swift 3 Whole Module Optimization Issue

2016-12-22 Thread Jun Zhang via swift-users
Hi, everyone. I think I found a swift 3 whole module optimization issue. The code below, when building with release configuration and running on an iOS 10 real device, will always causes a crash. import UIKit > class ViewController: UIViewController { > override func viewDidLoad() { >

Re: [swift-users] Bls: Bls: module (de)-initialization

2016-12-22 Thread Joe Groff via swift-users
> On Dec 21, 2016, at 7:29 PM, Mr Bee wrote: > > Sorry for not being clear. My english isn't very good either. > > What I meant was static module linking (loading and unloading) for Swift > modules. Also with initialization and deinitialization for Swift modules. > > It's alright then. I just

Re: [swift-users] Weird protocol behaviour.

2016-12-22 Thread Rien via swift-users
IMO the error message says it all: Playground execution failed: error: MyPlayground8.playground:9:5: error: cannot invoke 'foo' with an argument list of type '(P)' foo(x) ^ MyPlayground8.playground:9:5: note: expected an argument list of type '(A)' foo(x) ^ I.e. you are passing

[swift-users] Weird protocol behaviour.

2016-12-22 Thread Mikhail Seriukov via swift-users
Hello community! I' wondering if somebody can explain this to me. Please take look at the snippet. protocol P {} struct X:P {} func foo(_ x:A) {} func bar() { //let x = X() // this compiles let x = X() as P // this does not compile. Why? foo(x) } I expect the both cases to work thou

Re: [swift-users] Bls: Bls: module (de)-initialization

2016-12-22 Thread Glenn L. Austin via swift-users
> On Dec 21, 2016, at 7:29 PM, Mr Bee via swift-users > wrote: > > Sorry for not being clear. My english isn't very good either. > > What I meant was static module linking (loading and unloading) for Swift > modules. Also with initialization and deinitialization for Swift modules. > > It's al