# Future directions of Property Wrappers

**URL:** <https://forums.swift.org/t/future-directions-of-property-wrappers/27934>\
**Category:** Discussion\
**Tags:** propertywrapper\
**Created:** [August 15, 2019, 8:29pm UTC](https://forums.swift.org/t/future-directions-of-property-wrappers/27934 "2019-08-15T20:29:02Z")\
**Posts on this page:** 1\
**Page:** 2

<div class="post-metadata">

**Author:** ![tikitu](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tikitu/32/4635_2.png) [@tikitu](https://forums.swift.org/u/tikitu)\
**Post date:** [November 5, 2020, 11:10am UTC](https://forums.swift.org/t/future-directions-of-property-wrappers/27934/23 "2020-11-05T11:10:52Z")

</div>

> [@Douglas\_Gregor](#):
>
> ```swift
> // Once again, the problem with this in today's property wrappers
> // implementation is that every instance ends up storing the range, even
> // though by construction it can't ever be different from instance to
> // instance. That's a real waste. So what if we have a notion of "shared info
> // property wrappers" that live on the type and get instantiated?
> 
> ```

Using property wrappers with `Codable` gives another reason to want something like this: the decoder implementation has no access to the "shared info" values. We can't give `Clamped` a `Decodable` conformance (because where would the range value come from?), so as soon as we use `@Clamped` on a member of a `Decodable` type we're forced to implement a custom `init(from:)` for that type.

(I have another use case in mind: converting an optional codable member to non-optional by giving a default fallback value, to deal with json that skips keys with default values. I'm not sure if a solution that works for `@Clamped` would already make this possible though, because of complications to do with the autosynthesized decoder's handling of missing keys. Not having access to the default value in the property-wrapper's `Decodable` implementation is certainly _one_ of the things in the way, however.)

[Previous page](https://forums.swift.org/t/future-directions-of-property-wrappers/27934.md?page=1)
