Reflection is likely to be tackled in Swift 5, no? So realistically, this could be on track for Swift 6 or 7. Let&#39;s postpone discussion until then.<br><br><br><div class="gmail_quote"><div dir="ltr">On Tue, Oct 11, 2016 at 15:59 David Sweeris via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto" class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">On Oct 11, 2016, at 12:40, Anton Zhilin via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br class="gmail_msg"><br class="gmail_msg"></div><blockquote type="cite" class="gmail_msg"><div dir="ltr" class="gmail_msg"><div class="m_-1272261771439787227markdown-here-wrapper gmail_msg"><p style="margin:0px 0px 1.2em!important" class="gmail_msg">Hello Ted,<br class="gmail_msg">First of all, this topic belongs to reflection, which is specifically stated to be out of scope of Swift 4 Phase 1. So all considerations are purely theoretical for now.<br class="gmail_msg">That said, I also thought about this problem. The best I could imagine is something along the following lines:</p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px" class="gmail_msg"><code class="m_-1272261771439787227hljs m_-1272261771439787227language-swift gmail_msg" style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline;white-space:pre-wrap;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important;display:block;overflow-x:auto;padding:0.5em;color:rgb(51,51,51);background:rgb(248,248,248)"><span class="m_-1272261771439787227hljs-keyword gmail_msg" style="color:rgb(51,51,51);font-weight:bold">var</span> builder = <span class="m_-1272261771439787227hljs-type gmail_msg" style="color:rgb(68,85,136);font-weight:bold">StructBuilder</span>(name: <span class="m_-1272261771439787227hljs-string gmail_msg" style="color:rgb(221,17,68)">&quot;Person&quot;</span>)
builder.addProperty(name: <span class="m_-1272261771439787227hljs-string gmail_msg" style="color:rgb(221,17,68)">&quot;name&quot;</span>, type: <span class="m_-1272261771439787227hljs-type gmail_msg" style="color:rgb(68,85,136);font-weight:bold">String</span>.<span class="m_-1272261771439787227hljs-keyword gmail_msg" style="color:rgb(51,51,51);font-weight:bold">self</span>)
builder.addProperty(name: <span class="m_-1272261771439787227hljs-string gmail_msg" style="color:rgb(221,17,68)">&quot;age&quot;</span>, type: <span class="m_-1272261771439787227hljs-type gmail_msg" style="color:rgb(68,85,136);font-weight:bold">Int</span>.<span class="m_-1272261771439787227hljs-keyword gmail_msg" style="color:rgb(51,51,51);font-weight:bold">self</span>)
builder.addComputedProperty(name: <span class="m_-1272261771439787227hljs-string gmail_msg" style="color:rgb(221,17,68)">&quot;description&quot;</span>, getter: { (this: <span class="m_-1272261771439787227hljs-type gmail_msg" style="color:rgb(68,85,136);font-weight:bold">Any</span>) -&gt; <span class="m_-1272261771439787227hljs-type gmail_msg" style="color:rgb(68,85,136);font-weight:bold">String</span> <span class="m_-1272261771439787227hljs-keyword gmail_msg" style="color:rgb(51,51,51);font-weight:bold">in</span> ... })
builder.addComformance(<span class="m_-1272261771439787227hljs-type gmail_msg" style="color:rgb(68,85,136);font-weight:bold">CustomStringConvertible</span>.<span class="m_-1272261771439787227hljs-keyword gmail_msg" style="color:rgb(51,51,51);font-weight:bold">self</span>)
<span class="m_-1272261771439787227hljs-keyword gmail_msg" style="color:rgb(51,51,51);font-weight:bold">let</span> type: <span class="m_-1272261771439787227hljs-type gmail_msg" style="color:rgb(68,85,136);font-weight:bold">Any</span>.<span class="m_-1272261771439787227hljs-type gmail_msg" style="color:rgb(68,85,136);font-weight:bold">Type</span> = builder.build()
</code></pre>
<p style="margin:0px 0px 1.2em!important" class="gmail_msg">Obviously, to interact with such dynamic types and their objects, we need the whole working reflection system that we don’t have right now.</p></div></div></blockquote></div><div dir="auto" class="gmail_msg">I *think* that&#39;s only true for non-generic code, and types that aren&#39;t subclasses... I think...<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Anyway, I&#39;m starting to wonder if some code I&#39;m trying to write might be impossible without either this feature, or some/all of the stuff from the generics manifesto. So put me down as, in principle, a strong +1 (pending details of the proposal when it actually gets written for Swift 10).</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">- Dave Sweeris </div></div>_______________________________________________<br class="gmail_msg">
swift-evolution mailing list<br class="gmail_msg">
<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
</blockquote></div>