# Proposed change of plans for read accessors

**URL:** <https://forums.swift.org/t/proposed-change-of-plans-for-read-accessors/17722>\
**Category:** Compiler\
**Created:** [November 7, 2018, 12:41am UTC](https://forums.swift.org/t/proposed-change-of-plans-for-read-accessors/17722 "2018-11-07T00:41:03Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![John\_McCall](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/john_mccall/32/1351_2.png) [@John\_McCall](https://forums.swift.org/u/John_McCall)\
**Post date:** [November 7, 2018, 9:57pm UTC](https://forums.swift.org/t/proposed-change-of-plans-for-read-accessors/17722/2 "2018-11-07T21:57:12Z")

</div>

Going over the stdlib looking for places to adopt `@_borrowed` (strawman spelling; see [Add a @\_borrowed attribute to force the use of an opaque read accessor by rjmccall · Pull Request #20403 · apple/swift · GitHub](https://github.com/apple/swift/pull/20403) or the [associated forum thread](https://forums.swift.org/t/value-ownership-when-reading-from-a-storage-declaration/15076)), there's not much.

At least arguably required for move-only types:

- `Collection.subscript(Index)` and its refinement on `MutableCollection`
- `_SequenceWrapper._base` (unless this should go the opposite direction and become a `consuming` method)

The following are possible minor optimizations:

- `Error._domain`, which will almost exclusively return a constant value — but using `read` in that case might not actually be an optimization over doing a no-op retain/release
- `RawRepresentable.rawValue`, which I think will usually return a constant value, and which may need to be borrowed for move-only correctness
- `_AnyHashableBox._canonicalBox` (not sure about this one at all)
- `Encoder.codingPath` and `KeyedEncodingContainerProtocol.codingPath`
- `LazySequenceProtocol.elements` and `LazyCollectionProtocol.elements`

---

_[View the full topic](https://forums.swift.org/t/proposed-change-of-plans-for-read-accessors/17722)._
