Question to the language experts: Would this feature also allow for inout
parameters in subscripts?
struct S {
static subscript <T>(value: inout T) -> T {
set {
value = newValue
}
}
}
Not by the proposal implementation itself, but as some followup feature.
I would need a combination of the pitched feature and the above:
public subscript (context: Context, storage: Storage) -> Value {
get {
storage.value
}
}
public subscript (context: Context, storage: inout Storage) -> Value {
set {
storage.value = newValue
}
}
This would allow a nice optimization for property wrappers on value types, while keeping the design nearly the same for reference types.
If the answer to the above question is 'Yes' then I think it's another good motivation for this proposal.