[swift-evolution] [Pitch] Adding accessibility specifiers to @available
tony.allevato at gmail.com
Tue Aug 22 11:07:34 CDT 2017
A few months ago (before Swift 5 chatter started), I pitched an idea to
improve the use of @availability in third-party code by eliminating
deprecation warnings in same-file references
We had some good discussion there about who needed same-file deprecation
vs. same-module deprecation and so forth, and I was convinced that a better
approach would be to allow @available to be enforced based on accessibility.
More recently, another contributor had a similar idea for unavailable
that I unfortunately missed when it was posted.
So, I've jotted down my ideas to add accessibility specifiers to @available
in an early draft here
started an implementation
(The syntax is just one possibility; the one presented here was easy to
Some of the key points:
* Library authors often need to make something deprecated/unavailable
externally while still permitting its use internally (or lower, like at the
* It is not possible to do so today without the compiler emitting
diagnostics. Thus, libraries/frameworks that are evolving are littered with
build noise that make those libraries appear to be poorly maintained.
* IMO, accessibility-based diagnostics attached to the declaration
(library-author-controlled) are better than diagnostic-suppression blocks
(client-controlled, e.g. @SuppressWarnings("deprecation") in Java) because
the latter hides important information that the library author is trying to
communicate. However, this proposal does not preclude the addition of
something like that either.
Some of the ideas I've written up seem to be closely related to Jordan Rose
and John McCall's library evolution
be particularly interested in their thoughts about whether the ideas they
present there collide/conflict with this idea, or if they would work well
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution