SwiftMessage function the horizon?

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
mrbungle
Enthusiast
Enthusiast
Posts: 143
Joined: Wed Dec 30, 2020 3:18 am

SwiftMessage function the horizon?

Post by mrbungle »

The Cocoamessage function is very useful for macOS users, but over time, Cocoa has been progressively phased out. Will a future version of PB support an equivalent for Swift functions?

Thank you
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: SwiftMessage function the horizon?

Post by wilbert »

Did you encounter any methods you can't call ?

From what I understand both Swift and Objective-C use objc_msgSend which is also what CocoaMessage does.
Windows (x64)
Raspberry Pi OS (Arm64)
mrbungle
Enthusiast
Enthusiast
Posts: 143
Joined: Wed Dec 30, 2020 3:18 am

Re: SwiftMessage function the horizon?

Post by mrbungle »

Good to know. It seems some functions like the Swift UI's switch button toggle may only be available in Swift, but I could be wrong.
r-i-v-e-r
User
User
Posts: 20
Joined: Thu May 09, 2024 5:18 pm

Re: SwiftMessage function the horizon?

Post by r-i-v-e-r »

wilbert wrote: Sun Jun 02, 2024 4:58 pm Did you encounter any methods you can't call ?

From what I understand both Swift and Objective-C use objc_msgSend which is also what CocoaMessage does.
This isn't strictly accurate.

Swift code can interop with Obj-C APIs relatively simply (using objc_* / sel_* / class_* functions under-the-hood), but there do exist some Swift-only APIs which are unavailable to Obj-C (at least trivially speaking, i.e., they lack Obj-C runtime bridging).

In general, Swift is less dynamic than Obj-C. So for something like SwiftUI, you'd import functions directly from the framework and call them in accordance with the Swift calling convention. You can do this in PureBasic (or C/Obj-C/etc.), but it'll be somewhat of a pain using anything but Swift as you've got to care for runtime specifics, name (de)mangling, etc. For this same reason, a SwiftMessage(...) function makes less sense.
mrbungle
Enthusiast
Enthusiast
Posts: 143
Joined: Wed Dec 30, 2020 3:18 am

Re: SwiftMessage function the horizon?

Post by mrbungle »

Thank you for clarifying
Post Reply