# \[Discussion\] Inclusion of CasePaths into the language

**URL:** <https://forums.swift.org/t/discussion-inclusion-of-casepaths-into-the-language/53024>\
**Category:** Discussion\
**Created:** [October 24, 2021, 5:03pm UTC](https://forums.swift.org/t/discussion-inclusion-of-casepaths-into-the-language/53024 "2021-10-24T17:03:12Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![stephencelis](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/stephencelis/32/2675_2.png) [@stephencelis](https://forums.swift.org/u/stephencelis)\
**Post date:** [October 24, 2021, 6:55pm UTC](https://forums.swift.org/t/discussion-inclusion-of-casepaths-into-the-language/53024/9 "2021-10-24T18:55:57Z")

</div>

Subscripts are not currently capable of doing what a case path (or even a writable optional-chained path) needs to do because the type returned from the getter is different from the type sent to the setter:

- The getter is optional
- The setter is non-optional

This behavior would either need to be special cased by the compiler, or subscript/property syntax would need to change to support this. Pseudosyntax:

```swift
subscript<Value>(
  casePath: CasePath<Self, Value>
) -> Value? {
  get { … }
  nonoptional set { … }
}

```

I’d rather not get into design details, though, without a means of implementing. But if a person familiar with the compiler is interested in working on an implementation, I’d be more than happy to help with the design.

---

_[View the full topic](https://forums.swift.org/t/discussion-inclusion-of-casepaths-into-the-language/53024)._
