Pitch #2: Extend Property Wrappers to Function and Closure Parameters

This is fantastic! I only have relatively small comments below.

For the closure case, we might need to require parentheses around a single, attributed parameter to disambiguate between attributes that apply to the parameter and those that apply to the closure, eg, the ForEach closure would be:

{ (@Binding shoppingItem) in ...}

This bit is interesting. Ever since SE-0003, parameters have been immutable. I feel like we shouldn’t let property wrappers change that, even when the wrappedValue is nonmutating.

Property wrappers on stored struct properties already interact with parameters when we synthesize the memberwise initializer. Is there a common subset between that synthesis and this proposal that we can document here? Perhaps for some set of property wrappers the memberwise init can be described as if it used this feature?

I’m looking forward to using this feature, thank you Holly and Filip!

Doug

5 Likes