- What is your evaluation of the proposal?
+1 generally, with some reservations about naming/syntax
- Is the problem being addressed significant enough to warrant a change to Swift?
Yes, IMO an extensible declaration feature similar to Annotations is one of the biggest things currently missing in Swift. This addresses one of the clearest use cases as is shown by how many things it could replace in Swift itself, and could also be used to implement a number of often desired capabilities that would normally require a change to the language or that do not belong in the standard library but are currently impossible/impractical to implement.
Syntax Reservations
1. I'm not sure I see a need to add syntax rules ($propertyName
) for something where I would expect the use to be, if anything, discouraged. Is there a reason propertyName.backingStorage
or something of the like can't be used?
2. I'm not a fan of @propertyDelegate
being the naming. At the very least I think the "@" should be dropped as it seems to hold no current function other than to look similar to the thing being implemented, but more generally I'm not sure delegate
should be used as a keyword.
Given this type of syntax could (and hopefully will) be added to functions/methods and parameters (e.g. oft-requested improvements to [weak self] in closures), I would prefer a well planned out naming scheme that nicely includes the likely future use cases. Things that come to mind are declarationProtocol
and identityProtocol
, or if property is desired, propertyProtocol
.
That's not to say it should be a protocol. I don't think their current capabilities could properly support this type of feature in a clear and concise manner.
- Does this proposal fit well with the feel and direction of Swift?
Yes, in the functionality it enables, no in the ways previously expressed. I'm hopeful it could enable better support for meta-programming and possibly some QOL features e.g. @CodingKey(name: ":custom_field:")
for Codable
implementations...just a thought )
- If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?
I've used Annotations in Java/Kotlin a decent amount. Those are pretty different in scope than this, but seems to be solving some of the same problems in a similar way.
- How much effort did you put into your review? A glance, a quick reading, or an in-depth study?
semi-detailed read through and a long-time desire for this type of feature.