"throws" is the part that's not representable in Obj-C. Why are you using
it? If you're interacting with method_getImplementation, you need to think
like the Obj-C runtime.
https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtHowMessagingWorks.ht
Still trying on this (copied the code directly, Foo is actually XCTestCase):
typealias TestMethod = @convention(c) (XCTestCase) throws -> Void
This seagulls the compiler with “error: '(XCTestCase) throws -> Void' is not
representable in Objective-C, so it cannot be used with '@convention(c)’”. I
> Is there a way that avoids branching?
Don’t know. Have you profiled
let r = a > b ? 1 : 0
to know it is an issue?
>
> So, according to Xcode, "true" and "a > b" both have type "Bool". I don't
> know why the compiler allows one and not the other, except that it's literal,
> and I guess ther
For a function such as bar() above, the type you want to cast the IMP to
would probably be "@convention(c) (Foo, Selector) -> ()".
On Sun, Nov 20, 2016 at 9:05 PM, Jeff Kelley wrote:
> Thanks Jacob! I tried using unsafeBitCast, but it fails with the
> following: “fatal error: can't unsafeBitCast
Thanks Jacob! I tried using unsafeBitCast, but it fails with the following:
“fatal error: can't unsafeBitCast between types of different sizes”. I
considered wrapping every call in a closure that calls objc_msgSend(), but
alas, that’s not exposed to Swift. I have another approach in mind, so I’l
> On Nov 20, 2016, at 19:52 , Jon Shier wrote:
>
> Except in that case true isn’t a Bool but an NSNumber, which is why you can
> initialize an Int from it. It seems trivially easy to add an Int extension to
> do what you want though.
Is there a way that avoids branching?
So, according to Xco
Except in that case true isn’t a Bool but an NSNumber, which is why you can
initialize an Int from it. It seems trivially easy to add an Int extension to
do what you want though.
Jon
> On Nov 20, 2016, at 10:48 PM, Rick Mann via swift-users
> wrote:
>
> It seems I can't do this:
>
> let r
It seems I can't do this:
let r = Int(a > b)
but I can do it with a literal:
let r = Int(true)
I'd like to do this to implement signum without branching, but perhaps that's
not possible.
--
Rick Mann
rm...@latencyzero.com
___
swift-users mailing
Thank you, Hooman, that's very educational.
> On Nov 20, 2016, at 10:09 , Hooman Mehr wrote:
>
> Let me explain this a bit further:
>
> Swift generic programming is very different from C++ template programming.
> Swift compiler needs to type-check generic code on spot, not while
> instantiati
Let me explain this a bit further:
Swift generic programming is very different from C++ template programming.
Swift compiler needs to type-check generic code on spot, not while
instantiating the template (because in Swift, instantiation can occur at
runtime if the generic code is from a differe
10 matches
Mail list logo