<div dir="ltr"><div>Hi Joe,</div><div><br></div><div>I respect the choice of the team to use Custom[Debug]StringConvertible in lieu of summary. At the same time, in my opinion the output of dump() has become significantly more difficult to read (c.f. unit tests in <a href="https://github.com/apple/swift/pull/838/files">https://github.com/apple/swift/pull/838/files</a>). Would you and the team be open to exploring alternative solutions that improve the readability of dump() without increasing API surface area? For example, perhaps the reflection machinery itself should have special handling for some of the built-in types. If not, I&#39;ll consider this discussion thread complete.</div><div><br></div><div>Thanks,</div><div>Austin</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 5, 2016 at 3:22 PM, Jordan Rose <span dir="ltr">&lt;<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>Getting custom summaries for the common CG types certainly seems reasonable. We&#39;d have to get approval from the appropriate teams at Apple, but I can&#39;t see any objections.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Jordan</div></font></span><div><div class="h5"><div><br></div><br><div><blockquote type="cite"><div>On Dec 30, 2015, at 9:55, Joe Groff via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br><div><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">I believe &#39;summary&#39; is obsolete, and you&#39;re supposed to use Custom[Debug]StringConvertible to customize your type&#39;s reporting now.</span><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">-Joe</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br><div><blockquote type="cite"><div>On Dec 29, 2015, at 10:38 PM, Austin Zheng via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br><div><div dir="ltr">Hi all,<div><br></div><div>I&#39;d like to gauge reaction for a proposal I was considering: adding to the standard library&#39;s Mirror type a &#39;summary&#39; property, and the option to initialize a Mirror with a custom summary. If no custom summary is provided, the summary would default to the string produced by calling String(reflecting: subject) on the subject at the time of mirror creation.</div><div><br></div><div>Some context: right now, there are two APIs for mirrors in the standard library: CustomReflectable, which is publicly exposed and relies on the conforming type creating a Mirror object, and _Reflectable, which relies on the conforming type having a companion type conforming to _MirrorType. A short-term goal is to migrate the standard library&#39;s types off the _Reflectable API and have them use the CustomReflectable API, and changing dump() accordingly.</div><div><br></div><div>The extant implementation of dump() uses a property on _MirrorType called &quot;summary&quot;. (This is where e.g. &quot;4 elements&quot; comes from when you dump() an array.) &quot;summary&quot; is absent from Mirror or any types related to CustomReflectable. I asked Joe Groff about this and the rationale was that it was deemed too similar to debugDescription (or String(reflecting: foo)) to be worth carrying over.</div><div><br></div><div>I would like to suggest that there might be a purpose for &quot;summary&quot;:</div><div><br></div><div>- Types with children, especially container types like arrays, often print out a description of their children as part of their debugDescription or description, redundant when using an API like dump() which provides a structural representation of the children of the subject. In such cases a lighter-weight description (like &quot;3 elements&quot;) might be more appropriate to represent to the user.</div><div><br></div><div>- Certain types like CGRect don&#39;t conform to CustomStringConvertible, CustomDebugStringConvertible, Streamable, etc. Having a custom summary for these types customized by the corresponding Mirror would allow for a &#39;pretty&#39; representation during reflection in lieu of the ugly one generated by the runtime without making more substantial changes to the API which might break third-party code (such as conforming CGRect to any of the aforementioned protocols).</div><div><br></div><div>I know that Mirror (and reflection as a whole) are being considered for major design changes, so this would be a minor transient change to make the API easier to work with in the meantime.</div><div><br></div><div>Please let me know whether or not you think this proposed change is meaningful and worthwhile, or if you have any questions.</div><div><br></div><div>Best,</div><div>Austin</div></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=RoDF4MveSEMYBIqIJA6ub1g8cOZ-2BVYvqV-2FqygPhjPn9QSfLonyCZl-2BHuC4mjrTgtUo5RzgLB9UXxR-2ForNODpFEpVzHt7-2Fr8kYPe7xWw0WSRm0iPZ-2FKGcvwn2wKbxFgPOLk6-2BfoqiB97R0O-2ByNupoHk6T-2FHRE2d2LcvD5bDdvVEFBNBYWKmQWpV2K-2FhigeugT4HH-2FlnbfPOh-2BL0CY4fhsopB3LNCmozFpoBBNAeZm-2FOY-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0px!important;margin:0px!important;padding:0px!important"><span> </span>_______________________________________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div></blockquote></div><br></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=ZEz4qHYnXhPr3bBPu-2FxP4tN3HfWKL-2FtJpqkQ0gkOVSDKRyuqnR0DRjHU2nm6cjcotwTPzRPONaUp6oQHq32jzvg2VnMJH60Z3b11pBklp7AG8resQ88FQG82veT6IcuH3tV6q0bAQWdrgQUX2yrvVUVTRDFMI8sqN5nGi5xvyqGKlkTGNv721vI6GGyrIGcFIj4afg2k71kwCU9ZAou6lV8kdabi9gTPgpTVGozLWCY-3D" alt="" width="1" height="1" border="0" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;min-height:1px!important;width:1px!important;border-width:0px!important;margin:0px!important;padding:0px!important"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important"><span> </span>_______________________________________________</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">swift-evolution mailing list</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="mailto:swift-evolution@swift.org" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">swift-evolution@swift.org</a><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br></div></div></div></blockquote></div><br></div>