Re: [swift-users] The case of broken polymorphism or "Cannot convert value of type to expected argument type"?

2017-02-16 Thread Slava Pestov via swift-users
Hi Isaac, This is not about associated types. Rather, the issue is that a ‘Thing’ is a ‘Something’, but you are casting it to ‘Something’. The two types are not related; in general, if A is a subtype of B, then G is not a subtype of G. https://en.wikipedia.org/wiki/Covariance_and_contravarianc

Re: [swift-users] ambiguous minus operator

2017-02-16 Thread Zhao Xin via swift-users
I don't know if you are using an IDE, but in Xcode. I can just cmd+mouse left click to see the code headers. Zhaoxin On Fri, Feb 17, 2017 at 2:22 AM, Jon Shier via swift-users < swift-users@swift.org> wrote: > I’ve had good luck with being able to click the candidates in > cases like thi

[swift-users] Problems installing Swift on Ubuntu

2017-02-16 Thread Mohit Athwani via swift-users
I am a noob too and I got Swift to compile on Ubuntu 16.04 LTS using the following command from the swift/utils directory: ./build-script --preset=buildbot_linux_1604 install_destdir=/tmp/install installable_package=/tmp/swift.tar.gz And then running swift with: /tmp/install/bin/swift my_code.swi

Re: [swift-users] I have a problems to install Swift on Ubuntu 16.04

2017-02-16 Thread Mishal Shah via swift-users
Hi Francesco, Which toolchain are you using? Is it the development or swift 3.1 snapshot and which build did you download swift.org? Thanks, Mishal Shah > On Feb 15, 2017, at 10:42 AM, Francesco via swift-users > wrote: > > I followed all the procedures indicated on the Swift site to instal

Re: [swift-users] ambiguous minus operator

2017-02-16 Thread Jon Shier via swift-users
I’ve had good luck with being able to click the candidates in cases like this so Xcode will navigate to those bits of code. However, in this case I think the issue is that the candidates weren’t from user code but from the standard library, which Xcode has all sorts of issues navigating

Re: [swift-users] ambiguous minus operator

2017-02-16 Thread Jordan Rose via swift-users
> As usual the candidates are unknown. Just on this particular note, this is a terrible presentation issue and totally something we Apple people need to fix in Xcode, but you can usually see what the candidates were in the build log. Jordan > On Feb 16, 2017, at 07:56, J.E. Schotsman via swif

Re: [swift-users] How to return value in void * C pointer ?

2017-02-16 Thread Quinn "The Eskimo!" via swift-users
On 16 Feb 2017, at 15:59, Biala via swift-users wrote: > I have to implement a callback method that is called by the API. As a > variable I get a class with void * member. I have to allocate some object in > memory and assign this void* member to point to it. I don’t really understand this qu

Re: [swift-users] ambiguous minus operator

2017-02-16 Thread Saagar Jha via swift-users
DispatchTimeInterval.nanoseconds expects an Int, while uptimeNanoseconds is an UInt64 (an thus so is their difference). You can “fix” this by adding an explicit cast: func -(time1: DispatchTime, time2: DispatchTime) -> DispatchTimeInterval { return DispatchTimeInterval.nanoseconds(Int(ti

[swift-users] How to return value in void * C pointer ?

2017-02-16 Thread Biala via swift-users
Hello, Using the Apple core audio I come to this problem: I have to implement a callback method that is called by the API. As a variable I get a class with void * member. I have to allocate some object in memory and assign this void* member to point to it.How can I do this in SWIFT? Regards,Ale

[swift-users] Searching thru many threads; Linux dev

2017-02-16 Thread Félix Fischer via swift-users
Hi! Sorry for my noobness. I have two questions that may or may not be very apt. 1) How do I search through the threads of the mailing list? I'm looking for answers to Q2 2) What kind of environment can I set up for programming for Swift on Linux? I have a slow, old pc, so I can't quite afford th

[swift-users] I have a problems to install Swift on Ubuntu 16.04

2017-02-16 Thread Francesco via swift-users
I followed all the procedures indicated on the Swift site to install Swift on Ubuntu 4.16, but when I enter the terminal command "swift" gives me this error: can not execute binary file: executable format can invalid, help me solve the problem, thank you. ;-)

[swift-users] The case of broken polymorphism or "Cannot convert value of type to expected argument type"?

2017-02-16 Thread Isaac Rivera via swift-users
Hello, list! I am trying to find my way around Swift’s protocol limitations. It appears that in general, any protocol with declared associatedtype will break polymorphism? Take the case below which does not compile. All "Thing” instances are "Something” but they can’t be passed around or coerce

Re: [swift-users] ambiguous minus operator

2017-02-16 Thread Rien via swift-users
I don’t know about the candidates But the uptimeNanoseconds is a UInt64 and as such you should probably use substractWithOverflow. var a: UInt64 = 12 var b: UInt64 = 25 let result = UInt64.subtractWithOverflow(a, b) if result.overflow { print("Overflow") } else { let answer = result.0

[swift-users] ambiguous minus operator

2017-02-16 Thread J.E. Schotsman via swift-users
Hello, I am trying to define an operator that subtracts dispatch times: #import Dispatch func -( time1: DispatchTime, time2: DispatchTime ) -> DispatchTimeInterval { return DispatchTimeInterval.nanoseconds( time2.uptimeNanoseconds - time1.uptimeNanoseconds ) } Compiler

Re: [swift-users] UnsafePointer to UInt64

2017-02-16 Thread Rien via swift-users
Excellent! I had not seen the bitPattern initializer before… Regards, Rien Site: http://balancingrock.nl Blog: http://swiftrien.blogspot.com Github: http://github.com/Balancingrock Project: http://swiftfire.nl > On 16 Feb 2017, at 14:47, Martin R wrote: > > // Int to pointer: > let ptr =

Re: [swift-users] UnsafePointer to UInt64

2017-02-16 Thread Martin R via swift-users
// Int to pointer: let ptr = UnsafePointer(bitPattern: 123)! print(ptr) // 0x007b // Pointer to Int: let int = Int(bitPattern: ptr) print(int) // 123 Int has the same size as a pointer on both 32-bit and 64-bit platforms. Regards, Martin > On 16 Feb 2017, at 14:27, Rien via swift-us

[swift-users] UnsafePointer to UInt64

2017-02-16 Thread Rien via swift-users
What would be the easiest (and fastest) way to convert a pointer to an (unsigned)integer? Ptr -> String -> Int seems a bit cumbersome to me :-) Regards, Rien Site: http://balancingrock.nl Blog: http://swiftrien.blogspot.com Github: http://github.com/Balancingrock Project: http://swiftfire.nl