Skip to content

Commit abbc852

Browse files
authored
Merge pull request #2200 from apple/clarify-0376
[SE-0376] Clarify backDeployed attribute
2 parents 016d3c7 + 31f0298 commit abbc852

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

proposals/0376-function-back-deployment.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99

1010
## Introduction
1111

12+
This proposal introduces a `@backDeployed` attribute to allow ABI-stable libraries to make their own public APIs available on older OSes. When a `@backDeployed` API isn't present in the library that ships with an older OS, a client running on that OS can still use the API because a fallback copy of its implementation has been emitted into the client.
13+
14+
With `@backDeployed`, a function may be emitted into clients as a fallback copy of _itself_. Note that the attribute doesn't mark a function as a fallback implementation of some _other_ function, and therefore it doesn't help one module to extend the availability of APIs declared in some _other_ module.
15+
16+
## Motivation
17+
1218
Resilient Swift libraries, such as the ones present in the SDKs for Apple's platforms, are distributed as dynamic libraries. Authors of these libraries use `@available` annotations to indicate the operating system version that a declaration was introduced in. For example, suppose this were the interface of ToastKit, a library that is part of the toasterOS SDK:
1319

1420
```swift
@@ -126,8 +132,6 @@ extension Toaster {
126132
}
127133
```
128134

129-
Developers familiar with JavaScript may recognize these generated compatibility functions as [polyfills](https://remysharp.com/2010/10/08/what-is-a-polyfill).
130-
131135
When the deployment target of the client app is at least toasterOS 2.0, the compiler can eliminate the branch in `makeBatchOfToast_thunk(_:)` and therefore make `makeBatchOfToast_fallback(_:)` an unused function, which reduces the unnecessary bloat that could otherwise result from referencing a back deployed API.
132136

133137
### Restrictions on declarations that may be back deployed

0 commit comments

Comments
 (0)