[swift-dev] Questions about _Reflectable and CustomReflectable
Joe Groff
jgroff at apple.com
Tue Dec 8 14:56:43 CST 2015
> On Dec 8, 2015, at 11:44 AM, Austin Zheng via swift-dev <swift-dev at swift.org> wrote:
>
> 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
More information about the swift-dev
mailing list