Hello,

I had a question about the intended behavior/functionality of mirrors in 
Swift/Swift Foundation types.

In general, should a Mirror reference all variables in a type? 
I’m not sure what scope mirrors should/will have, but it does seem like some of 
iterating through children has been done:
http://stackoverflow.com/questions/34601802/how-can-i-check-if-a-property-has-been-set-using-swift-reflection

Should mirrors only reference public+ variables? Or private ones too? Is it 
meant to be up to the author?


With respect to Foundation, I was starting to silence some warnings with ‘as 
Any’ (https://bugs.swift.org/browse/SR-2737), but I noticed this code in 
URLComponents.swift at 
https://github.com/apple/swift-corelibs-foundation/blob/master/Foundation/URLComponents.swift#L313:

if let s = self.scheme { c.append((label: "scheme", value: s)) }
if let u = self.user { c.append((label: "user", value: u)) }
etc...


Should public properties be mirrored even if their values are nil?
c.append((label: "scheme", value: s as Any))
c.append((label: "user", value: u as Any))
etc...

What rules should there be to determine what gets mirrored?

Regards,
Will Stanton

_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev

Reply via email to