<font size="2"><span style="background-color:rgba(255,255,255,0)">Here is an expanded proposal for the syntax for a Scala style memberwise syntax and equivalent code, specification is via an example rather than formal syntax since this is easier to follow. Note it is like Scala’s syntax but it is ‘Swiftified” (in particular still retains `init` keyword).<br><br>    class Ex public init(<br>        superParam: sPType = sPInitial,<br>        private label privateParam: pPType = pPInitial,<br>        calculatedParam: cPType = cPInitial<br>    ): SuperType(superParam) {<br>        calculatedParam: cPType {<br>            get {…}<br>            set {…}<br>        }<br>    }<br><br>This gets translated to:<br><br>    class Ex: SuperType(superParam) { {<br>        private privateParam: pPType = pPInitial,<br>        public init(superParam: sPType = sPInitial, label privateParam: pPType = pPInitial, calculatedParam: cPType = cPInitial) {<br>            // 1. Call super<br>            super.init(superParam)<br>            // 2. Initialize generated parameters and existing parameters<br>            self.privateParame = privateParam<br>            self.calculatedParam = calculatedParam<br>        }<br>        calculatedParam: cPType {<br>            get {…}<br>            set {…}<br>        }<br>    }<br><br>Because the syntax is so short it is part of this proposal to remove both the current default and memberwise initialisers thus simplifying the language overall (remove two features, add one) and at the same time gain power, which is a rare situation and therefore I would suggest optimal.<br><br>It is also more powerful than the proposed `memberwise init(..)` and/or existing automatic `inits` in the following ways:<br><br>1. Allows `lets` to have a default value.<br>2. Allows other properties including computed properties to have a default value.<br>3. Allows any `super.init` to be called (not restricted to `super.init()`).<br>4. Allows control of which properties participate in the `init` (they are listed in the brackets and are not in a super call and are not an existing property).<br>5. Allows private properties to be initialised.<br>6. Allows properties including private properties to have a label instead of their actual name and hence not expose internals (also allows migration of implementation whilst retaining external interface).<br>7. Allows calls to the generated `init` that don’t specify all members, i.e. for `struct Ex init(i: Int = 0, s: String = “&quot;) {}` the following are allowed `Ex()`, `Ex(i: 1)`, `Ex(s: “A”)`, and `Ex(i: 2, s: “B”)`.<br>8. Allows visibility of automatically generated `init` to be controlled.<br>9. Supports property behaviours.<br>10. Does not require a new keyword.<br><br>The downsides of the proposal relative to  `memberwise init(..)` and/or existing automatic `inits` are:<br><br>1. That people would need to be careful when laying out their code otherwise the first line could become long (a bit of pretty printing solves this).<br>2. Existing structs/classes that have automatically generated inits would need to be refactored, e.g. `CGRect` would become `struct CGRect init(var origin: CGPoint, var size: CGSize) {}` (a migration tool would help here).<br><br>Other than the downsides listed above the proposal does everything the current proposal and current implementation does and more (more also listed above) and is simpler to both explain and implement.<br><br>The above more than addresses the reasons given in the current proposal for not using the Scala syntax and demonstrates superiority in many areas. However if it were the current proposal or nothing I would go with the current proposal since something is better than nothing.<br></span></font><br>On Wednesday, 6 January 2016, Matthew Johnson &lt;<a href="mailto:matthew@anandabits.com">matthew@anandabits.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><blockquote type="cite"><div>On Jan 5, 2016, at 12:12 PM, Tino Heth &lt;<a href="javascript:_e(%7B%7D,&#39;cvml&#39;,&#39;2th@gmx.de&#39;);" target="_blank">2th@gmx.de</a>&gt; wrote:</div><br><div><div><br><blockquote type="cite">The “type parameter list” syntax is sugar that could be implemented as a layer on top of the current proposal or could be implemented orthogonally.<br></blockquote>Hi Howard,<br>I&#39;ve heard this argument before, so I&#39;ll repeat my answer as well:<br>Both offers don&#39;t make sense, it&#39;s either one way or the other (or something completely different).<br></div></div></blockquote><div><br></div><div>I don’t think it’s clear whether both make sense or not.  They are not mutually exclusive and are aimed at solving related, but different problems.  If we adopt the current proposal, the Kotlin / Scala syntax *might* make sense for some use cases.  It would depend upon whether the current proposal is considered too verbose in enough cases or not.  This may or may not turn out to be the case.</div><div><br></div><div>The reason my proposal looks the way it does is because there are specific goals it intends to achieve and problems it is intended to solve.  These goals and problems are not adequately addressed by the Kotlin / Scala syntax.</div><br><blockquote type="cite"><div><div>If diversity starts here, why not have &quot;const&quot; and &quot;val&quot; beside &quot;let&quot;, or allow &quot;fn&quot; and &quot;lambda&quot;?<br><br>@Matthew: Please, if you support something, then say so - using clear words, not phrases like &quot;could be implemented”.<br></div></div></blockquote><br></div><div>This phrasing is plenty clear IMO.  I am stating a possibility.  I do not have a position on whether or not it is a good idea at the moment.</div><div><br></div><div>I have made some modifications to the proposal over the last few days.  These changes have been partly motivated by considering the conversation we have had.  You may wish to give it another look.  If so, please look here: <a href="https://github.com/anandabits/swift-evolution/blob/flexible-memberwise-initialization/proposals/0018-flexible-memberwise-initialization.md" target="_blank">https://github.com/anandabits/swift-evolution/blob/flexible-memberwise-initialization/proposals/0018-flexible-memberwise-initialization.md</a>.  There is currently an open PR for the latest change so it is not in the main Swift evolution repo yet.</div><div><br></div><div>The most recent change includes a discussion of why it does not use the Scala / Kotlin syntax.  You may not like the choice but I hope you can at least understand the rationale (even if you disagree with it).</div><div><br></div><br></div></blockquote><br><br>-- <br>  -- Howard.<br><br>