On 23 June 2017 at 02:39, Mike Kluev <[email protected]> wrote:
>
> if a single private var has no implicit / explicit default value then
> default member wise initialiser is not created (#change) and attempt to
> opt-in to have one gives an error. let's call it proposal #5. this
> particular one is not a backward compatible change, the old code will have
> to be modified.
>
alternatively:
in case of private members with no implicit / explicit default values, we
may have a private memberwise initialiser with all private member
parameters as well. you can create your own public initializer and call
through the private memberwise initializer if needed
struct S {
var a: Int
var b: Int = 0
private var c: Int
private var d: Int?
// autogenerated (#change)
//
// private init(a: Int, b: Int = 0, c: Int, d: Int? = nil) { // private
// self.a = a
// self.b = b
// self.c = c
// self.d = d
// }
init(... whatever ...) {
self.init(a: ...., b: ....., c: ...., d: ....)
}
}
Mike
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution