Thanks for the hard work! I think this has become a pretty solid feature. I agree with most of the proposal, with a few minor points:
If the outermost property wrapper defines a projectedValue
property, a local computed property representing the outermost projectedValue
will be synthesized and named per the original parameter name prefixed with a dollar sign ( $
).
This doesn't seem to handle mutating get
projectedValue
. Though that paragraph is already overlong, and it's quite a minor scenario, so
.
Does this also allow unapplied function reference with function arguments, i.e., log(value:)
is allowed and is interpreted as log
? This is heavily implied by UFR section, but I couldn't find an explicit example in the proposal.
Property wrappers on function parameters must support init(wrappedValue:)
.
Rationale : This is an artificial limitation to prevent programmers from writing functions with an argument label that cannot be used to call or reference the function.
Maybe we can drop this requirement. We don't seem to have any problem with unusable function:
func foo(_: Never) { } // ok...
init(projectedValue:)
is a new initializer here. Have you considered adding this back to the original property wrapper?
var projected: Binding = ...
@Binding var $value = projected
Aside from consistency's sake, I couldn't find a scenario where this could be useful, so maybe we don't need to add it (even as a future direction). It's out-of-scope for this pitch anyway.
Do you also plan to include use this feature for synthesized memberwise initializer? My impression is that it's left for future direction, but @filip-sakel's reply seems to imply otherwise:
Or maybe I just misinterpreted the discussion.
Property-wrapper parameters with arguments in the wrapper attribute cannot be passed a projected value.
What about an empty argument?
func foo(@Wrapper() a: Int) { }
This could be an interesting way to disable pass-by-projected-value. I think we should also disallow foo($a)
here.