Skip to content

Commit 5606d6c

Browse files
committed
Write up why I don't want to add @unsafe(message: "blah")
1 parent 65eed26 commit 5606d6c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

proposals/nnnn-strict-memory-safety.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,10 @@ This proposal introduced strict safety checking as an opt in mode and not an [*u
433433
* Interoperability with the C family of languages is an important feature for Swift. Most C(++) APIs are unlikely to ever adopt the safety-related attributes described above, which means that enabling strict safety checking by default would undermine the usability of C(++) interoperability.
434434
* Swift's current (non-strict) memory safety by default is likely to be good enough for the vast majority of users of Swift, so the benefit of enabling stricter checking by default is unlikely to be worth the disruption it would cause.
435435

436+
### Optional `message` for the `@unsafe` attribute
437+
438+
We could introduce an optional `message` argument to the `@unsafe` attribute, which would allow programmers to indicate *why* the use of a particular declaration is unsafe and, more importantly, how to safely write code that uses it. However, this argument isn't strictly necessary: a comment could provide the same information, and there is established tooling to expose comments to programmers that wouldn't be present for this attribute's message, so we have omitted this feature.
439+
436440
## Acknowledgments
437441

438442
This proposal has been greatly improved by the feedback from Félix Cloutier, Gábor Horváth, Frederick Kellison-Linn, Karl Wagner, and Xiaodi Wu.

0 commit comments

Comments
 (0)