[swift-evolution] [Pitch] Property reflection

Matthew Johnson matthew at anandabits.com
Fri May 27 08:21:12 CDT 2016



Sent from my iPad

> On May 27, 2016, at 2:25 AM, Austin Zheng <austinzheng at gmail.com> wrote:
> 
> Would you be willing to elaborate? Are you thinking of model objects whose properties are all completely hidden using 'private' and whose APIs are available only through methods? What if there existed something like "private(reflectable)", for properties you really want to keep both private and exposed to the reflection machinery? Or maybe a property behavior to do the same thing once that feature becomes a reality...

'private(reflectable)' would mean private for the purpose of reflection if we follow the same interpretation as 'private(set)'.  Maybe you meant 'private public(reflectable)' - as in private, but public for the purpose of reflection only.

> 
> Austin
> 
> 
>> On May 26, 2016, at 11:52 PM, David Hart <david at hartbit.com> wrote:
>> 
>> 
>> 
>>> On 27 May 2016, at 04:44, Austin Zheng via swift-evolution <swift-evolution at swift.org> wrote:
>>> 
>>> My personal preference would be to honor access control, and consider ser/de separately (especially since there are so many other possible considerations for that feature). Access control in Swift isn't just another safety feature, it's also a boundary for things like the optimizer.
>>> 
>>> To be honest, I expect the first big use of a feature like this to be turning JSON or XML received from a network call into model objects for an app. There are quite a few Objective-C libraries that use KVC to implement this functionality.
>> 
>> That's what I want to use it for and I'm fairly sure we need access to private properties for that.
> 



More information about the swift-evolution mailing list