<div dir="ltr"><div class="markdown-here-wrapper" style=""><p style="margin:0px 0px 1.2em!important">Hello Ted,<br>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>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"><code class="hljs language-swift" 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;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="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">var</span> builder = <span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">StructBuilder</span>(name: <span class="hljs-string" style="color:rgb(221,17,68)">&quot;Person&quot;</span>)
builder.addProperty(name: <span class="hljs-string" style="color:rgb(221,17,68)">&quot;name&quot;</span>, type: <span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">String</span>.<span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">self</span>)
builder.addProperty(name: <span class="hljs-string" style="color:rgb(221,17,68)">&quot;age&quot;</span>, type: <span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">Int</span>.<span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">self</span>)
builder.addComputedProperty(name: <span class="hljs-string" style="color:rgb(221,17,68)">&quot;description&quot;</span>, getter: { (this: <span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">Any</span>) -&gt; <span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">String</span> <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">in</span> ... })
builder.addComformance(<span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">CustomStringConvertible</span>.<span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">self</span>)
<span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">let</span> type: <span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">Any</span>.<span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">Type</span> = builder.build()
</code></pre>
<p style="margin:0px 0px 1.2em!important">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 title="MDH:PGRpdiBjbGFzcz0iZ21haWxfZXh0cmEiPkhlbGxvIFRlZCw8L2Rpdj48ZGl2IGNsYXNzPSJnbWFp
bF9leHRyYSI+Rmlyc3Qgb2YgYWxsLCB0aGlzIHRvcGljIGJlbG9uZ3MgdG8gcmVmbGVjdGlvbiwg
d2hpY2ggaXMgc3BlY2lmaWNhbGx5IHN0YXRlZCB0byBiZSBvdXQgb2Ygc2NvcGUgb2YgU3dpZnQg
NCBQaGFzZSAxLiBTbyBhbGwgY29uc2lkZXJhdGlvbnMgYXJlIHB1cmVseSB0aGVvcmV0aWNhbCBm
b3Igbm93LjwvZGl2PjxkaXYgY2xhc3M9ImdtYWlsX2V4dHJhIj5UaGF0IHNhaWQsIEkgYWxzbyB0
aG91Z2h0IGFib3V0IHRoaXMgcHJvYmxlbS4gVGhlIGJlc3QgSSBjb3VsZCBpbWFnaW5lIGlzIHNv
bWV0aGluZyBhbG9uZyB0aGUgZm9sbG93aW5nIGxpbmVzOjwvZGl2PjxkaXYgY2xhc3M9ImdtYWls
X2V4dHJhIj48YnI+PC9kaXY+PGRpdiBjbGFzcz0iZ21haWxfZXh0cmEiPmBgYHN3aWZ0PC9kaXY+
PGRpdiBjbGFzcz0iZ21haWxfZXh0cmEiPnZhciBidWlsZGVyID0gU3RydWN0QnVpbGRlcihuYW1l
OiAiUGVyc29uIik8L2Rpdj48ZGl2IGNsYXNzPSJnbWFpbF9leHRyYSI+YnVpbGRlci5hZGRQcm9w
ZXJ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