Questions about _Reflectable and CustomReflectable


(Austin Zheng) #1

Hello devs,

I have two questions about the _Reflectable and CustomReflectable protocols in the stdlib. (These are both in context of Jira ticket SR-88.)

First, I notice that _Reflectable encompasses both CustomReflectable and CustomPlaygroundQuickLookable's functionality. It looks like there are a couple of _MirrorTypes that exist only to provide quicklook functionality. Can I assume that, quicklook behavior aside, a _MirrorType conformer that is hardcoded to report zero children can be replaced by the default runtime mirror (e.g. the type who the _FoobarMirrorType belongs to doesn't need to conform to CustomReflectable)?

Secondly, is there an explicit replacement for _MirrorType's "summary" property? As-is, the current Mirror type provides no analogous property, and in most cases the existing custom mirrors just return the object's description. Was the "reflection summary" functionality broken out into a third protocol, or dropped altogether?

Best regards,
Austin


(Joe Groff) #2

Hello devs,

I have two questions about the _Reflectable and CustomReflectable protocols in the stdlib. (These are both in context of Jira ticket SR-88.)

First, I notice that _Reflectable encompasses both CustomReflectable and CustomPlaygroundQuickLookable's functionality. It looks like there are a couple of _MirrorTypes that exist only to provide quicklook functionality. Can I assume that, quicklook behavior aside, a _MirrorType conformer that is hardcoded to report zero children can be replaced by the default runtime mirror (e.g. the type who the _FoobarMirrorType belongs to doesn't need to conform to CustomReflectable)?

There's some accretion here. We didn't have time to phase out _MirrorType completely, so the new Swift 2 interfaces are still implemented for some times by falling back to _MirrorType's implementation.

Secondly, is there an explicit replacement for _MirrorType's "summary" property? As-is, the current Mirror type provides no analogous property, and in most cases the existing custom mirrors just return the object's description. Was the "reflection summary" functionality broken out into a third protocol, or dropped altogether?

IIRC it was decided that the summary wasn't usefully different from debugDescription; I believe playgrounds just use the debugDescription now.

-Joe

ยทยทยท

On Dec 8, 2015, at 11:44 AM, Austin Zheng via swift-dev <swift-dev@swift.org> wrote: