# Revisit synthesized init(from decoder:) for structs with default property values

**URL:** <https://forums.swift.org/t/revisit-synthesized-init-from-decoder-for-structs-with-default-property-values/12296>\
**Category:** Pitches\
**Tags:** codable\
**Created:** [May 1, 2018, 4:35pm UTC](https://forums.swift.org/t/revisit-synthesized-init-from-decoder-for-structs-with-default-property-values/12296 "2018-05-01T16:35:17Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![anandabits](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/anandabits/32/355_2.png) [@anandabits](https://forums.swift.org/u/anandabits)\
**Post date:** [May 1, 2018, 9:04pm UTC](https://forums.swift.org/t/revisit-synthesized-init-from-decoder-for-structs-with-default-property-values/12296/6 "2018-05-01T21:04:05Z")

</div>

> [@itaiferber](#):
>
> We can’t get around the fact that the variable is immutable — having more complex behaviors around something that already appears “magic” enough I think could leave us in a worse spot.

@itaiferber @stephencelis I discussed the issue of immutable properties with default values extensively with @Chris_Lattner3 while working on the [flexible memberwise initialization](https://github.com/apple/swift-evolution/blob/master/proposals/0018-flexible-memberwise-initialization.md) proposal.

There are many good reasons to want the semantics to be such that the default value is _only_ used when an initializer does not explicitly provide a value. The value of such properties would still be _immutable_ but they may have more than one path to initialization and therefore may take on different values _in different instances_ of the type. It sounds to me like this is the model @stephencelis had in mind when posting to this thread. His post is a great example of why we may wish to reconsider the semantics.

My proposal was deferred but the core team indicated willingness to at least _consider_ modifying the semantics of immutable properties. See [common feedback and points](https://forums.swift.org/t/review-se-0018-flexible-memberwise-initialization/939/22) in the rationale for the core team's decision. If anyone is interested in the discussion between Chris and I, see the [draft thread](https://forums.swift.org/t/proposal-draft-flexible-memberwise-initialization/698/1). There was also extensive discussion in the [review thread](https://forums.swift.org/t/review-se-0018-flexible-memberwise-initialization/935).

The good news is that aside from the initializers synthesized by `Codable` I don't think there would be any source breakage involved in such a change. We would simply be making code that is not valid today valid in the future. I would really love to see this topic revisited. Perhaps now is the time.

---

_[View the full topic](https://forums.swift.org/t/revisit-synthesized-init-from-decoder-for-structs-with-default-property-values/12296)._
