This was discussed in a previous thread, and our consensus was that the closure capture list syntax would work best for this. For example
final class C {}
struct Car {
let make: String
let model: String
let year: Int
let reference: C
}
let car = Car(make: "Honda", model: "E", year: 2021, reference: C())
let [make, model, year] = car
This would allow for binding to different names and also weak
and unowned
modifiers. This would also be less invasive to the parser I hope, since you'd be able to use parts of the grammar dedicated to capture lists:
var [weak weakReference = reference] = car
Alternatively, it could look closer to the dictionary syntax:
var [weak weakReference: reference] = car