-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do we handle availability? #266
Comments
There are effectively two versions that affect availability and what we should do: the deployment target and the SDK version. To illustrate, let's assume an API
*Note that I don't really know a case where an API has been removed, but we can handle it if need be. |
From the above, we can see that the logic in |
This comment was marked as duplicate.
This comment was marked as duplicate.
We need to do both a static and a dynamic check - the static one is fairly straightforward, but I'm unsure of how we should do the dynamic one? I would have thought that clang just called some library function, but it's actually implemented as a compiler builtin, which calls into CoreFoundation and reads Do we really need that as well? Or can we perhaps get by with just reading |
Actually, turns out the We could reconsider the check to be just |
Swift's Though they use (a weak symbol to) |
There's a new RFC that would help with OS compile-time detection: rust-lang/rfcs#3379 (though we'd still want a macro for the compile-time + runtime detection fallback) |
A short, very incomplete list I made a while ago on different behaviour in
My conclusion was that it's not super important for the runtime i.e. (That said, it's of course still very important for the user to know, so we still need this feature in some shape or form). |
I wrote some ideas for how the availability check might work internally in this playground. |
We have |
This also affects the |
Have been working on this recently, I think there is value in exposing just the runtime lookup functionality of this (i.e. an |
Another idea would be to have a flag |
Yet another idea would be to develop this in |
I suggest that whenever the topic of OS version checking or availability come up in Had some experiments earlier in the year too looking at how possible it would be to duplicate the codegen LLVM injects into builds to handle dynamic checking at runtime via |
Yeah, I'm actually in the process of writing the Alongside that, I'm considering implementing a |
I'd try and keep |
In Apple's Objective-C headers, most classes and methods are annotated with an availability attribute such as
API_AVAILABLE(macos(10.13), ios(11.0), watchos(4.0), tvos(11.0))
; this is absolutely a great idea (!!!), it very cleanly allows you to mark which APIs you may use, and which ones are not usable on your current deployment target.We should have some way of doing the same as
@available
in Objective-C; however, since we are not a compiler likeclang
is, this is quite tricky!A quick demonstration of what I want:
For this, Contexts and capabilities come to mind, similar to how it would be useful for autorelease pools, but alas, we can't do that yet, so this will probably end up as a debug assertions runtime check.
See also the original SSheldon/rust-objc#111, a WIP implementation can be found in #212.
The text was updated successfully, but these errors were encountered: