Before Swift 5.4, my mental model for what "property wrapping" was, was the same as officially documented:
When you use a property wrapper, you write the management code once when you define the wrapper, and then reuse that management code by applying it to multiple properties.
You apply a wrapper to a property by writing the wrapper’s name before the property as an attribute.
When you apply a wrapper to a property, the compiler synthesizes code that provides storage for the wrapper and code that provides access to the property through the wrapper.
That is to say, the "property" being "wrapped" was the name that came after
@Wrapper var—which had to be what was previously known as a property. But now, property wrappers can be applied to local variables. So, has Swift 5.4 redefined what "property" itself means?
- Is a "local variable" actually a "function property" or "closure property" now?
- Has Swift 5.4 accidentally solved the problem of not having a term for both
var-things? Are they all properties?
- And if the term "property" has just been extended from applying only to type-scope, is a function-scoped function now a "function method"? Or should the term "method" be avoided when talking about Swift, as "function" and "property" are all that's needed, aside from scope?
Alternatively, it's possible that nothing needs to change other than the documentation, and our mental models: if the properties being "wrapped" are
projectedValue, that could work too. But that's not how the feature is advertised.
The definitions for "property" and "method" never felt at home to me in Swift, which has a lot of nesting power outside of just the one right inside a type. We can of course be hand-wavy when talking about this stuff, but I think 5.4 just added the first new level of confusion about the concept since Swift's initial release. It would be nice to have precise, unconfusing language.