Skip to content

Commit 0303bea

Browse files
committed
[BitwiseCopyable] Future direction for composition
1 parent 8811170 commit 0303bea

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

proposals/nnnn-bitwise-copyable.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,19 @@ In order to allow that, a new field could be added to `MemoryLayout`.
272272
Most Swift types have the property that their representation can be relocated in memory with direct memory operations.
273273
This could be represented with a `BitwiseMovable` protocol that would be handled similarly to `BitwiseCopyable`.
274274

275+
### BitwiseCopyable as a composition
276+
277+
Some discussion in the pitch thread discussed how `BitwiseCopyable` could be defined as the composition of several protocols.
278+
For example,
279+
```swift
280+
typealias BitwiseCopyable = Bitwise & Copyable & DefaultDeinit
281+
```
282+
Such a definition remains possible after this proposal.
283+
284+
Because `BitwiseCopyable` is a marker protocol, its ABI is rather limited.
285+
Specifically, it only affects name mangling.
286+
If, in a subsequent proposal, the protocol were redefined as a composition, symbols into which `BitwiseCopyable` was mangled could still be mangled in the same way, ensuring ABI compatibility.
287+
275288
## Alternatives considered
276289

277290
### Alternate Spellings

0 commit comments

Comments
 (0)