<div dir="ltr">Here are a couple of examples I had in mind.<div><br></div><div>* Arrays (from test/1_stdlib/Runtime.swift:1348), dumping an array with 5 elements:</div><div><br></div><div>BEFORE:</div><div><div>▿ 5 elements</div><div><span class="" style="white-space:pre">        </span>- [0]: a.MultiPayloadTagBitsSmallNonGenericEnumWithDefaultMirror.MacWrite</div><div><span class="" style="white-space:pre">        </span>- [1]: a.MultiPayloadTagBitsSmallNonGenericEnumWithDefaultMirror.MacPaint</div><div><span class="" style="white-space:pre">        </span>- [2]: a.MultiPayloadTagBitsSmallNonGenericEnumWithDefaultMirror.FileMaker</div><div><span class="" style="white-space:pre">        </span>▿ [3]: a.MultiPayloadTagBitsSmallNonGenericEnumWithDefaultMirror.ClarisWorks</div><div>    <span class="" style="white-space:pre">        </span>- ClarisWorks: true</div><div>       ▿ [4]: a.MultiPayloadTagBitsSmallNonGenericEnumWithDefaultMirror.HyperCard</div><div>    <span class="" style="white-space:pre">        </span>- HyperCard: false</div></div><div><br></div><div>AFTER:</div><div><div>▿ [a.MultiPayloadTagBitsSmallNonGenericEnumWithDefaultMirror.MacWrite, a.MultiPayloadTagBitsSmallNonGenericEnumWithDefaultMirror.MacPaint, a.MultiPayloadTagBitsSmallNonGenericEnumWithDefaultMirror.FileMaker, a.MultiPayloadTagBitsSmallNonGenericEnumWithDefaultMirror.ClarisWorks(true), a.MultiPayloadTagBitsSmallNonGenericEnumWithDefaultMirror.HyperCard(false)]</div><div><span class="" style="white-space:pre">        </span>- [0]: a.MultiPayloadTagBitsSmallNonGenericEnumWithDefaultMirror.MacWrite</div><div><span class="" style="white-space:pre">        </span>- [1]: a.MultiPayloadTagBitsSmallNonGenericEnumWithDefaultMirror.MacPaint</div><div><span class="" style="white-space:pre">        </span>- [2]: a.MultiPayloadTagBitsSmallNonGenericEnumWithDefaultMirror.FileMaker</div><div><span class="" style="white-space:pre">        </span>▿ [3]: a.MultiPayloadTagBitsSmallNonGenericEnumWithDefaultMirror.ClarisWorks(true)</div><div>    <span class="" style="white-space:pre">        </span>- ClarisWorks: true</div><div>    ▿ [4]: a.MultiPayloadTagBitsSmallNonGenericEnumWithDefaultMirror.HyperCard(false)</div><div>    <span class="" style="white-space:pre">        </span>- HyperCard: false</div></div><div><br></div><div>* Dictionaries (from test/1_stdlib/ReflectionHashing.swift:43):</div><div><br></div><div>BEFORE:</div><div><div>▿ 5 key/value pairs</div><div>  ▿ [0]: (2 elements)</div><div>    - .0: Four</div><div>    - .1: 4</div><div>  ▿ [1]: (2 elements)</div><div>    ...</div><div><br></div><div>AFTER:</div><div>▿ [&quot;Four&quot;: 4, &quot;One&quot;: 1, &quot;Two&quot;: 2, &quot;Five&quot;: 5, &quot;Three&quot;: 3]</div><div>  ▿ [0]: (&quot;Four&quot;, 4)</div><div>    - .0: &quot;Four&quot;</div><div>    - .1: 4</div><div>  ▿ [1]: (&quot;One&quot;, 1)</div><div>    ...</div></div><div><br></div><div>* Dumping a CGRect (from test/1_stdlib/Reflection_objc.swift):</div><div><br></div><div>BEFORE:</div><div>(50.0, 60.0, 100.0, 150.0)<br></div><div><br></div><div>AFTER:</div><div>__C.CGRect(origin: __C.CGPoint(x: 50.0, y: 60.0), size: __C.CGSize(width: 100.0, height: 150.0))<br></div><div><br></div><div>Let me know if you&#39;d like more, although most are variants on the above.</div><div><br></div><div>Best,</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 5:37 PM, Dave Abrahams <span dir="ltr">&lt;<a href="mailto:dabrahams@apple.com" target="_blank">dabrahams@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"><br><div><span class=""><blockquote type="cite"><div>On Jan 5, 2016, at 5:28 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" style="font-family:AvenirNext-Regular;font-size:15px;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"><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<span> </span><a href="https://github.com/apple/swift/pull/838/files" target="_blank">https://github.com/apple/swift/pull/838/files</a>). </div></div></div></blockquote><div><br></div></span>Specific examples of readability regressions, please?</div><div><span class=""><br><blockquote type="cite"><div><div dir="ltr" style="font-family:AvenirNext-Regular;font-size:15px;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"><div>Would you and the team be open to exploring alternative solutions that improve the readability of dump() without increasing API surface area? </div></div></div></blockquote><div><br></div></span><div>Sure.</div><div><div class="h5"><br><blockquote type="cite"><div><div dir="ltr" style="font-family:AvenirNext-Regular;font-size:15px;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"><div>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" style="font-family:AvenirNext-Regular;font-size:15px;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 class="gmail_quote">On Tue, Jan 5, 2016 at 3:22 PM, Jordan Rose<span> </span><span dir="ltr">&lt;<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>&gt;</span><span> </span>wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style: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><font color="#888888"><div><br></div><div>Jordan</div></font></span><div><div><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><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=JfMPa-2F7wwZPzsZ3QKA8NjtONIYX4SjbWuUxtpfsTY2imXhV0ngybfDklUr3PVYgW7eTSDDgfmPKuVpewmItn3U6r0a8VuGKvhaf3rQOqByqm2bNPeKKXzu5qjlxPZVSg1gIVr9wwMTNF1Os9UngUIhm502TBLmIXvjC5Fxj2gy-2B8O4dMYKvwRvoGSaeewWkjZ9c42BM1MZ9xT9hRFRddM2PKaa5VeKcenzsAdY-2BDEsA-3D" alt="" width="1" height="1" border="0" style="font-family:AvenirNext-Regular;font-size:15px;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:AvenirNext-Regular;font-size:15px;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:AvenirNext-Regular;font-size:15px;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:AvenirNext-Regular;font-size:15px;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:AvenirNext-Regular;font-size:15px;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:AvenirNext-Regular;font-size:15px;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:AvenirNext-Regular;font-size:15px;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:AvenirNext-Regular;font-size:15px;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></div></div><span class="HOEnZb"><font color="#888888"><br><div>
-Dave<div><br></div><br>

</div>
<br></font></span></div></blockquote></div><br></div>