# Explicit Memberwise Initializers

**URL:** <https://forums.swift.org/t/explicit-memberwise-initializers/22893>\
**Category:** Pitches\
**Created:** [April 10, 2019, 2:52am UTC](https://forums.swift.org/t/explicit-memberwise-initializers/22893 "2019-04-10T02:52:00Z")\
**Posts on this page:** 1\
**Showing post:** 9

<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:** [April 10, 2019, 1:23pm UTC](https://forums.swift.org/t/explicit-memberwise-initializers/22893/9 "2019-04-10T13:23:02Z")

</div>

> [@jawbroken](#):
>
> Sure, I don't find `x...` to be less weird than `self.x` though. It is considerably more weird to me, both being an entirely new syntax (rather than reusing a standard way of referring to properties) and having ellipses that suggest it refers to something more than just `x` when it doesn't.

This syntax is borrowed from parameter pack expansion in [variadic generics](https://github.com/apple/swift/blob/master/docs/GenericsManifesto.md#variadic-generics). The ellipses represents the expansion of a pack. Swift doesn’t support variadic generics yet but [many of us hope it will someday](https://forums.swift.org/t/variadic-generics/20320). So while this syntax is new to Swift, I think it fits very well with the long term vision.

> [@jawbroken](#):
>
> And it gets even weirder when you start having to interpret something like `init((internal | externalLabel detail2)...)` .

This syntax represents pack composition followed by expansion of the composed pack. The alternative is to simply list out each property in the necessary order. I think pack composition is a powerful concept that would be useful. That said, it is something that could be moved to a future enhancement (possibly at the core team’s discretion). It isn’t strictly necessary for the initial proposal, although in my experience it is something that will be quite useful.

> [@jawbroken](#):
>
> even the simple option of just allowing `self.property` in argument lists reduces the number of non-whitespace characters in @Avi's example by 65%.

Reducing boilerplate is a significant part of the purpose of this proposal but I think highlighting the delta from the trivial is also very important. When all parameters have to be listed it is no longer clear whether they match the order of other initializers as well as the property declarations themselves without inspecting all of that code. When each initializer focuses exclusively on the details that deviate from memberwise initialization that information immediately pops to the foreground. This is very useful and gets lost when every initializer is required to explicitly list out every property it is initializing.

---

_[View the full topic](https://forums.swift.org/t/explicit-memberwise-initializers/22893)._
