[swift-evolution] [Proposal] Property behaviors
felixcca at yahoo.ca
Thu Dec 17 12:48:41 CST 2015
I'm in favor of the feature too. It addresses a real shortcoming in the language and it will make the syntax more general.
With my programming background, this looks like decorators applied specifically to properties. If this is a good way to think about it, then in case we want more for Swift 4, it might be a good idea to come up with a syntax that will easily be applicable to methods, free functions, types, enums, locals or anything else that could be decorated.
> Le 17 déc. 2015 à 13:26:49, David Owens II via swift-evolution <swift-evolution at swift.org> a écrit :
> The functionality looks like it is something that is definitely required to reduce the boiler-plate that Swift currently requires. However, this seems like a specific instance of a more general problem. For example, I run into a similar problem with working with other constructs, such as enums, where I want to provide specific “behaviors” for them that is just a bunch of boiler-plate code.
> It seems like this proposal could be a starting place to start flush out what a macro/preprocessor/boiler-plate-reducer would look like in Swift. As such, I would like to see a syntax that could be extended beyond properties. Maybe this system is limited in scope to only allow this generation in specific contexts, like this property behavior, especially to scope this proposal down.
> The short of it: I like the idea and it seems expandable to future concerns if syntax like attributes are used. And like you mentioned, these could be generate errors when used in the wrong contexts, such as lacking @behavior_function, or its equivalent.
> swift-evolution mailing list
> swift-evolution at swift.org
More information about the swift-evolution