<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">thank you, Goffredo, Anton, see inline<div class="">TedvG<br class=""><div><blockquote type="cite" class=""><div class="">On 11 Oct 2016, at 21:10, Goffredo Marocchi <<a href="mailto:panajev@gmail.com" class="">panajev@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class="">I quite like your builder pattern way of adding properties and methods :).<br class=""><br class="">Sent from my iPhone</div><div class=""><br class="">On 11 Oct 2016, at 19:40, Anton Zhilin via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="markdown-here-wrapper" style=""><p style="margin:0px 0px 1.2em!important" class="">Hello Ted,<br class="">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=""></p></div></div></div></blockquote></div></div></blockquote>The idea is not intended to be in a deadline/timeframe</div><div>could be Swift 7 for that :o) <br class=""><blockquote type="cite" class=""><div class=""><div dir="auto" class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="markdown-here-wrapper" style=""><p style="margin:0px 0px 1.2em!important" class="">.. 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=""><code class="language-swift hljs" 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)">"Person"</span>)
builder.addProperty(name: <span class="hljs-string" style="color:rgb(221,17,68)">"name"</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)">"age"</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)">"description"</span>, getter: { (this: <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">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" class="">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 class=""><br class=""></div></div></div></div></blockquote></div></div></blockquote><div>I don’t know how much reflection is needed in this context.</div><div>-Adding dynamic classes can be solved with incremental? recompiling </div><div>based on previously generated compiler reference metadata, </div><div>already present. (note that in debug mode there already is a lot of “reflection”</div><div>available)</div><div> - static entities defined at the initial compilation</div><div> - and cumulative for dynamic entities when additionaly compiled at run time.</div><div>As soon as a dynamically defined or redefined class (or struct) is compiled</div><div>it is then regarded as a static type, transparent to the application thus which instances </div><div>cannot be dynamically altered, because they are “tied” to the class definition.</div><div>Instance creation is then the same as with statically defined classes</div><div><br class=""></div><div>(but all this is a bit simplified of course, and I don’t know much about compilers.</div><div>Maybe similar to Smalltalk where methods/classes are precompiled separately)</div><div><br class=""></div><div>@ Chris: As a Compiler Pro could you say more about this and about the whole idea, Chris? </div><div><br class=""></div><div>Thanks</div><div>TedvG</div><div><br class=""></div><div><br class=""></div><div><br class=""></div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="auto" class=""><blockquote type="cite" class=""><div class=""><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; line-height: normal; font-family: 'Arial Black'; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;">Dynamic Class/Struct Definition At Run Time </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; line-height: normal; font-family: 'Avenir Next'; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 16px;"><span class="" style="-webkit-font-kerning: none;"></span><br class=""></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; line-height: normal; font-family: 'Avenir Next'; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;">At the time of this writing, 11 October 2016, it is not possible to define arbitrary </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; line-height: normal; font-family: 'Avenir Next'; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;">classes, structs </span><span class="" style="-webkit-text-stroke-width: initial;">and maybe other entities dynamically at run time in Swift. </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; line-height: normal; font-family: 'Avenir Next'; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-text-stroke-width: initial;">I have some idea about it, expressed in this message.</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; line-height: normal; font-family: 'Avenir Next'; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 16px;"><span class="" style="-webkit-font-kerning: none;"></span><br class=""></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; line-height: normal; font-family: 'Avenir Next'; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;">Creating class and other types dynamically should be as simple and as easy to understand </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; line-height: normal; font-family: 'Avenir Next'; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;">as possible, preferably with nearly the same style and syntax as the "regular" declarations,</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; line-height: normal; font-family: 'Avenir Next'; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> leaving things like "Meta""Type" T.Self etc. as transparent as possible. </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; line-height: normal; font-family: 'Avenir Next'; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;">That should in this context be "under the hood", as it is also the case </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; line-height: normal; font-family: 'Avenir Next'; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;">when defining static classes. </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; line-height: normal; font-family: 'Avenir Next'; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 16px;"><span class="" style="-webkit-font-kerning: none;"></span><br class=""></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; line-height: normal; font-family: 'Avenir Next'; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;">I have constructed the following (hypothetical) example code,</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; line-height: normal; font-family: 'Avenir Next'; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> which serves as just a "thinking model", so to speak.</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 14px;"><span class="" style="-webkit-font-kerning: none;"></span><br class=""></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);"><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);"> </span><span class="" style="-webkit-font-kerning: none;">// In this example we dynamically create and use </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);"><span class="" style="-webkit-font-kerning: none;"> // an example class named "Monolith"</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);"><span class="" style="-webkit-font-kerning: none;"> // First, we declare an "empty dynamic class"</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);"><span class="" style="-webkit-font-kerning: none;"> // (a slot) at compile time, that is later defined at run time.</span></div><div style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0); min-height: 13px;" class=""><span class="" style="-webkit-font-kerning: none;"> </span><br class="webkit-block-placeholder"></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); -webkit-text-stroke-color: rgb(186, 45, 162);"><span class="" style="-webkit-font-kerning: none;"> dynamic class</span><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);"> Monolith </span><span class="" style="color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);">// defined later just this line.</span></div><p class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> </span></p><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);"><span class="" style="-webkit-font-kerning: none;"> // Use a constructor that accepts </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);"><span class="" style="-webkit-font-kerning: none;"> // a string which contains a class definition, </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);"><span class="" style="-webkit-font-kerning: none;"> // exactly like one would define a class in Swift statically. </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);"><span class="" style="-webkit-font-kerning: none;"> // with the exception that name of the class is not specified. </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);"><span class="" style="-webkit-font-kerning: none;"> // It is replaced by placeholder, an underscore, because </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);"><span class="" style="-webkit-font-kerning: none;"> // the class name itself is inferred when declaring it. </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);"><span class="" style="-webkit-font-kerning: none;"> // Specifying the class name will throw an error.</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 13px;"><span class="" style="-webkit-font-kerning: none;"></span><br class=""></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(64, 64, 64); -webkit-text-stroke-color: rgb(64, 64, 64);"><span class="" style="-webkit-font-kerning: none; color: rgb(209, 47, 27); -webkit-text-stroke-color: rgb(0, 0, 0);"> </span><span class="" style="-webkit-font-kerning: none; color: rgb(186, 45, 162); -webkit-text-stroke-color: rgb(186, 45, 162);">var</span><span class="" style="-webkit-font-kerning: none; color: rgb(209, 47, 27); -webkit-text-stroke-color: rgb(0, 0, 0);"> </span><span class="" style="-webkit-font-kerning: none;">classDefStr</span><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);"> = </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(255, 45, 33); -webkit-text-stroke-color: rgb(255, 45, 33);"><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);"> </span><span class="" style="-webkit-font-kerning: none;">"class _ :SCNNode, AnInterface, AnotherInterface "</span><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);">+</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(255, 38, 0); -webkit-text-stroke-color: rgb(255, 38, 0);"><span class="" style="-webkit-font-kerning: none; color: rgb(209, 47, 27); -webkit-text-stroke-color: rgb(0, 0, 0);"> </span><span class="" style="-webkit-font-kerning: none;">"{var l = 9.0; var h = 4.0; var w = 1.0; " </span><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);">+</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(255, 38, 0); -webkit-text-stroke-color: rgb(255, 38, 0);"><span class="" style="-webkit-font-kerning: none;"> "var color = UIColor.blue;" </span><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);">+</span><span class="" style="-webkit-font-kerning: none;"> </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(255, 38, 0); -webkit-text-stroke-color: rgb(255, 38, 0);"><span class="" style="-webkit-font-kerning: none;"> "func volume() -> Double { return l * w * h} “</span><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);"> +</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none; color: rgb(209, 47, 27); -webkit-text-stroke-color: rgb(209, 47, 27);"> </span><span class="" style="-webkit-font-kerning: none;">aStringWithAdditionalComponentDefinitions + </span><span class="" style="-webkit-font-kerning: none; color: rgb(255, 45, 33); -webkit-text-stroke-color: rgb(255, 45, 33);">"}"</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 13px;"><span class="" style="-webkit-font-kerning: none;"></span><br class=""></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(87, 135, 38); -webkit-text-stroke-color: rgb(87, 135, 38);"><span class="" style="-webkit-font-kerning: none;"> // Of course, this class definition string can also be assembled</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(87, 135, 38); -webkit-text-stroke-color: rgb(87, 135, 38);"><span class="" style="-webkit-font-kerning: none;"> // completely programatically, read from a file or database, etc. </span></div><div style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 13px;" class=""><span class="" style="-webkit-font-kerning: none;"> </span><br class="webkit-block-placeholder"></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> </span><span class="" style="-webkit-font-kerning: none; color: rgb(186, 45, 162); -webkit-text-stroke-color: rgb(186, 45, 162);">func</span><span class="" style="-webkit-font-kerning: none;"> defMonolithClass()</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> {</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);"><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);"> </span><span class="" style="-webkit-font-kerning: none; color: rgb(186, 45, 162); -webkit-text-stroke-color: rgb(186, 45, 162);">do</span><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);"> </span><span class="" style="-webkit-font-kerning: none;">// try to define a class, NOT an instance.</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> {</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> </span><span class="" style="-webkit-font-kerning: none; color: rgb(186, 45, 162); -webkit-text-stroke-color: rgb(186, 45, 162);">try</span><span class="" style="-webkit-font-kerning: none;"> Monolith = </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> </span><span class="" style="-webkit-font-kerning: none; color: rgb(4, 51, 255); -webkit-text-stroke-color: rgb(4, 51, 255);">Meta.defineClass</span><span class="" style="-webkit-font-kerning: none;">(withString: classDefStr)</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> }</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(4, 51, 255); -webkit-text-stroke-color: rgb(4, 51, 255);"><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);"> </span><span class="" style="-webkit-font-kerning: none; color: rgb(186, 45, 162); -webkit-text-stroke-color: rgb(186, 45, 162);">catch</span><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);"> </span><span class="" style="-webkit-font-kerning: none;">Meta.classDefinitionError</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> {</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);"><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);"> </span><span class="" style="-webkit-font-kerning: none;">// handle a possible class dynamic compilation errors</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);"><span class="" style="-webkit-font-kerning: none;"> // e.g. syntax errors. symbols not found etc. </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> }</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(4, 51, 255); -webkit-text-stroke-color: rgb(4, 51, 255);"><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);"> </span><span class="" style="-webkit-font-kerning: none; color: rgb(186, 45, 162); -webkit-text-stroke-color: rgb(186, 45, 162);">catch</span><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);"> </span><span class="" style="-webkit-font-kerning: none;">Meta.classCreationConflict</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> {</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);"><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);"> </span><span class="" style="-webkit-font-kerning: none;">// class cannot be redefined </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);"><span class="" style="-webkit-font-kerning: none;"> // when instances of Monolith still exist.</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);"><span class="" style="-webkit-font-kerning: none;"> // This restriction is probably necessary.</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);"><span class="" style="-webkit-font-kerning: none;"> // Also, static classes defined at compile time</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);"><span class="" style="-webkit-font-kerning: none;"> // cannot be redefined</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> }</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 13px;"><span class="" style="-webkit-font-kerning: none;"></span><br class=""></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(87, 135, 38); -webkit-text-stroke-color: rgb(87, 135, 38);"><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);"> </span><span class="" style="-webkit-font-kerning: none;">// After successfully declaring our dynamic class,</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(87, 135, 38); -webkit-text-stroke-color: rgb(87, 135, 38);"><span class="" style="-webkit-font-kerning: none;"> // we can now add more features to it, like </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(87, 135, 38); -webkit-text-stroke-color: rgb(87, 135, 38);"><span class="" style="-webkit-font-kerning: none;"> // properties and dynamic extensions. (It is not</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(87, 135, 38); -webkit-text-stroke-color: rgb(87, 135, 38);"><span class="" style="-webkit-font-kerning: none;"> // possible of course to add statically defined extensions</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(87, 135, 38); -webkit-text-stroke-color: rgb(87, 135, 38);"><span class="" style="-webkit-font-kerning: none;"> </span><span class="" style="-webkit-text-stroke-width: initial;">// and protocols to a non-existing dynamic class at compile time.</span></div><div style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 13px;" class=""><span class="" style="-webkit-font-kerning: none;"> </span><span class="" style="color: rgb(87, 135, 38); -webkit-text-stroke-color: rgb(87, 135, 38); -webkit-text-stroke-width: initial;">// neither is it possible to do this at run time.)</span></div><div style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 13px;" class=""><span class="" style="-webkit-font-kerning: none;"> </span><br class="webkit-block-placeholder"></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> </span><span class="" style="-webkit-font-kerning: none; color: rgb(186, 45, 162); -webkit-text-stroke-color: rgb(186, 45, 162);">do</span><span class="" style="-webkit-font-kerning: none;"> </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);"><span class="" style="-webkit-font-kerning: none;"> </span><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);">{</span><span class="" style="-webkit-font-kerning: none;"> </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> </span><span class="" style="-webkit-font-kerning: none; color: rgb(186, 45, 162); -webkit-text-stroke-color: rgb(186, 45, 162);">try</span><span class="" style="-webkit-font-kerning: none;"> </span><span class="" style="-webkit-font-kerning: none; color: rgb(4, 51, 255); -webkit-text-stroke-color: rgb(4, 51, 255);">Meta.addPropertyTo</span><span class="" style="-webkit-font-kerning: none;">(Monolith,</span><span class="" style="-webkit-font-kerning: none; color: rgb(209, 47, 27); -webkit-text-stroke-color: rgb(209, 47, 27);">"mass"</span><span class="" style="-webkit-font-kerning: none;">, </span><span class="" style="-webkit-font-kerning: none; color: rgb(39, 42, 216); -webkit-text-stroke-color: rgb(39, 42, 216);">3.4</span><span class="" style="-webkit-font-kerning: none;">)</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> </span><span class="" style="-webkit-font-kerning: none; color: rgb(186, 45, 162); -webkit-text-stroke-color: rgb(186, 45, 162);">try</span><span class="" style="-webkit-font-kerning: none;"> </span><span class="" style="-webkit-font-kerning: none; color: rgb(4, 51, 255); -webkit-text-stroke-color: rgb(4, 51, 255);">Meta.addPropertyTo</span><span class="" style="-webkit-font-kerning: none;">(Monolith,</span><span class="" style="-webkit-font-kerning: none; color: rgb(209, 47, 27); -webkit-text-stroke-color: rgb(209, 47, 27);">"physics"</span><span class="" style="-webkit-font-kerning: none;">, PhysicsBody)</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> </span><span class="" style="-webkit-font-kerning: none; color: rgb(186, 45, 162); -webkit-text-stroke-color: rgb(186, 45, 162);">try</span><span class="" style="-webkit-font-kerning: none;"> </span><span class="" style="-webkit-font-kerning: none; color: rgb(4, 51, 255); -webkit-text-stroke-color: rgb(4, 51, 255);">Meta.addExtensionTo</span><span class="" style="-webkit-font-kerning: none;">(Monolith, someExtensionDefStr)</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> }</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(4, 51, 255); -webkit-text-stroke-color: rgb(4, 51, 255);"><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);"> </span><span class="" style="-webkit-font-kerning: none; color: rgb(186, 45, 162); -webkit-text-stroke-color: rgb(186, 45, 162);">catch</span><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);"> </span><span class="" style="-webkit-font-kerning: none;">Meta.classExtenderError</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> {</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);"><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);"> </span><span class="" style="-webkit-font-kerning: none;">// handle the error</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> }</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(4, 51, 255); -webkit-text-stroke-color: rgb(4, 51, 255);"><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);"> </span><span class="" style="-webkit-font-kerning: none; color: rgb(186, 45, 162); -webkit-text-stroke-color: rgb(186, 45, 162);">catch</span><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);"> </span><span class="" style="-webkit-font-kerning: none;">Meta.classCreationConflict</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> {</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);"><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);"> </span><span class="" style="-webkit-font-kerning: none;">// class definition cannot be altered </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);"><span class="" style="-webkit-font-kerning: none;"> // when instances of Monolith (still) exist.</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);"><span class="" style="-webkit-font-kerning: none;"> // This restriction seems to be necessary.</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);"><span class="" style="-webkit-font-kerning: none;"> // Also, static classes defined at compile time</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);"><span class="" style="-webkit-font-kerning: none;"> // cannot be extended dynamically. </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> }</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);"><span class="" style="-webkit-font-kerning: none;"> }</span></div><p class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> </span></p><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> ...</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 13px;"><span class="" style="-webkit-font-kerning: none;"></span><br class=""></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> defMonolithClass()</span></div><p class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> </span></p><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);"><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);"> </span><span class="" style="-webkit-font-kerning: none;">// After having dynamically declared the example class,</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);"><span class="" style="-webkit-font-kerning: none;"> // we can produce instances of it, like with any </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);"><span class="" style="-webkit-font-kerning: none;"> // other class. It throws an error</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);"><span class="" style="-webkit-font-kerning: none;"> // when the dynamic class has not been defined. </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0); min-height: 13px;"><span class="" style="-webkit-font-kerning: none;"></span><br class=""></div><div style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0); min-height: 13px;" class=""><span class="" style="-webkit-font-kerning: none;"> </span><br class="webkit-block-placeholder"></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> public </span><span class="" style="-webkit-font-kerning: none; color: rgb(186, 45, 162); -webkit-text-stroke-color: rgb(186, 45, 162);">let</span><span class="" style="-webkit-font-kerning: none;"> monolith = Monolith() </span></div><p class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> </span></p><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> </span><span class="" style="-webkit-font-kerning: none; color: rgb(186, 45, 162); -webkit-text-stroke-color: rgb(186, 45, 162);">let</span><span class="" style="-webkit-font-kerning: none;"> vol = monolith.volume</span></div><p class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> </span></p><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);"><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);"> monolith = </span><span class="" style="-webkit-font-kerning: none; color: rgb(186, 45, 162); -webkit-text-stroke-color: rgb(186, 45, 162);">nil</span><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);"> </span><span class="" style="-webkit-font-kerning: none;">// remove instance(s), pre ARC when we wish to </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);"><span class="" style="-webkit-font-kerning: none;"> // redefine it. </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 13px;"><span class="" style="-webkit-font-kerning: none;"></span><br class=""></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);"><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);"> defMonolithClass() </span><span class="" style="-webkit-font-kerning: none;">// redefine it, possibly with other definition parameters as in the first definition in this example.</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 13px;"><span class="" style="-webkit-font-kerning: none;"></span><br class=""></div><p class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0);"><span class="" style="-webkit-font-kerning: none;"> </span></p><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0); min-height: 13px;"><span class="" style="-webkit-font-kerning: none;"></span><br class=""></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;">Some examples for additional functionality</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0); min-height: 13px;"><span class="" style="-webkit-font-kerning: none;"></span><br class=""></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170); -webkit-text-stroke-color: rgb(112, 61, 170);"><span class="" style="-webkit-font-kerning: none; color: rgb(186, 45, 162); -webkit-text-stroke-color: rgb(186, 45, 162);">let</span><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);"> Bird: </span><span class="" style="-webkit-font-kerning: none;">DynamicClass</span><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);">?</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0); min-height: 13px;"><span class="" style="-webkit-font-kerning: none;"></span><br class=""></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); -webkit-text-stroke-color: rgb(0, 132, 0); min-height: 13px;"><span class="" style="-webkit-font-kerning: none;"></span><br class=""></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(4, 51, 255); -webkit-text-stroke-color: rgb(4, 51, 255);"><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);">Bird = </span><span class="" style="-webkit-font-kerning: none;">Meta.defineClass</span><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);">(</span><span class="" style="-webkit-font-kerning: none;">withString</span><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);">: classDefStr)</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 13px;"><span class="" style="-webkit-font-kerning: none;"></span><br class=""></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;">Bird = </span><span class="" style="-webkit-font-kerning: none; color: rgb(4, 51, 255); -webkit-text-stroke-color: rgb(4, 51, 255);">Meta.defineClass</span><span class="" style="-webkit-font-kerning: none;">(</span><span class="" style="-webkit-font-kerning: none; color: rgb(4, 51, 255); -webkit-text-stroke-color: rgb(4, 51, 255);">superClass</span><span class="" style="-webkit-font-kerning: none;">: StaticClass | DynamicClass,</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> </span><span class="" style="-webkit-font-kerning: none; color: rgb(4, 51, 255); -webkit-text-stroke-color: rgb(4, 51, 255);">interfaces</span><span class="" style="-webkit-font-kerning: none;">: [Protocol],</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> </span><span class="" style="-webkit-font-kerning: none; color: rgb(4, 51, 255); -webkit-text-stroke-color: rgb(4, 51, 255);">definitionString</span><span class="" style="-webkit-font-kerning: none;">: classItemsDefStr)</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 13px;"><span class="" style="-webkit-font-kerning: none;"></span><br class=""></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;">Bird = </span><span class="" style="-webkit-font-kerning: none; color: rgb(4, 51, 255); -webkit-text-stroke-color: rgb(4, 51, 255);">Meta.defineCopyOfClass</span><span class="" style="-webkit-font-kerning: none;">(</span><span class="" style="-webkit-font-kerning: none; color: rgb(4, 51, 255); -webkit-text-stroke-color: rgb(4, 51, 255);">class</span><span class="" style="-webkit-font-kerning: none;">: StaticClass| DynamicClass,</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> </span><span class="" style="-webkit-font-kerning: none; color: rgb(4, 51, 255); -webkit-text-stroke-color: rgb(4, 51, 255);">append</span><span class="" style="-webkit-font-kerning: none;">: classItemsDefString)</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 13px;"><span class="" style="-webkit-font-kerning: none;"></span><br class=""></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 13px;"><span class="" style="-webkit-font-kerning: none;"></span><br class=""></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 13px;"><span class="" style="-webkit-font-kerning: none;"></span><br class=""></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(4, 51, 255); -webkit-text-stroke-color: rgb(4, 51, 255);"><span class="" style="-webkit-font-kerning: none;">Meta.addpropertyTo</span><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);">(Monolith, </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> </span><span class="" style="-webkit-font-kerning: none; color: rgb(4, 51, 255); -webkit-text-stroke-color: rgb(4, 51, 255);">name</span><span class="" style="-webkit-font-kerning: none;">:</span><span class="" style="-webkit-font-kerning: none; color: rgb(209, 47, 27); -webkit-text-stroke-color: rgb(209, 47, 27);">"mass"</span><span class="" style="-webkit-font-kerning: none;">,</span><span class="" style="-webkit-font-kerning: none; color: rgb(4, 51, 255); -webkit-text-stroke-color: rgb(4, 51, 255);">initializeWith</span><span class="" style="-webkit-font-kerning: none;">: </span><span class="" style="-webkit-font-kerning: none; color: rgb(39, 42, 216); -webkit-text-stroke-color: rgb(39, 42, 216);">3.4, type: Float</span><span class="" style="-webkit-font-kerning: none;">) </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 13px;"><span class="" style="-webkit-font-kerning: none;"></span><br class=""></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(4, 51, 255); -webkit-text-stroke-color: rgb(4, 51, 255);"><span class="" style="-webkit-font-kerning: none;">Meta.addPropertyTo</span><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);">(Monolith,</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> name </span><span class="" style="-webkit-font-kerning: none; color: rgb(209, 47, 27); -webkit-text-stroke-color: rgb(209, 47, 27);">"Person"</span><span class="" style="-webkit-font-kerning: none;">,initializeWith: someValue</span><span class="" style="-webkit-font-kerning: none; color: rgb(39, 42, 216); -webkit-text-stroke-color: rgb(39, 42, 216);">, type: Inferred</span><span class="" style="-webkit-font-kerning: none;">) </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 13px;"><span class="" style="-webkit-font-kerning: none;"></span><br class=""></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(4, 51, 255); -webkit-text-stroke-color: rgb(4, 51, 255);"><span class="" style="-webkit-font-kerning: none;">Meta.addConstantPropertyTo</span><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);">(Monolith,</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;"> name </span><span class="" style="-webkit-font-kerning: none; color: rgb(209, 47, 27); -webkit-text-stroke-color: rgb(209, 47, 27);">"cow"</span><span class="" style="-webkit-font-kerning: none;">,initializeWithString: aString</span><span class="" style="-webkit-font-kerning: none; color: rgb(39, 42, 216); -webkit-text-stroke-color: rgb(39, 42, 216);">, </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(39, 42, 216); -webkit-text-stroke-color: rgb(39, 42, 216);"><span class="" style="-webkit-font-kerning: none;"> type: FourLeggedAnimal</span><span class="" style="-webkit-font-kerning: none; -webkit-text-stroke-color: rgb(0, 0, 0);">) </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 13px;"><span class="" style="-webkit-font-kerning: none;"></span><br class=""></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 13px;"><span class="" style="-webkit-font-kerning: none;"></span><br class=""></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 13px;"><span class="" style="-webkit-font-kerning: none;"></span><br class=""></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 13px;"><span class="" style="-webkit-font-kerning: none;"></span><br class=""></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;">In principle, variants of this could be used to define structs as well.</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 13px;"><span class="" style="-webkit-font-kerning: none;"></span><br class=""></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;">While Swift is mainly a statically typed language, recompilation or additional </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;">compilation and somehow link it al together is obviously necessary at run time, </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;">each time a dynamic structure is defined. </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;">Because of this, it will most probably have performance drawbacks </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;">at run time, but there are applications where that is acceptable.</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;">Also, there many applications where dynamic entities are not needed, </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;">and therefore relying only on statically defined objects, which run as fast as usual.</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 13px;"><span class="" style="-webkit-font-kerning: none;"></span><br class=""></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;">I haven't thought (yet) very much about possible side effects and conflicts. </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;">One of the restrictions probably is that one cannot or should not, alter the </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;">class definition (hierarchy) as long as instances of it exist.</span></div><div style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 13px;" class=""><span class="" style="-webkit-font-kerning: none;"> </span><br class="webkit-block-placeholder"></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;">How to implement this and can it be done? I know almost nothing about </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;">compiler design and construction I assume that it is very complicated, </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;">but if it can be done it would be great, making Swift even more powerful </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;">than it already is. </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 13px;"><span class="" style="-webkit-font-kerning: none;"></span><br class=""></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;">Interesting? </span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;">Of course, there might be better ways to do this, it's just a (my) start of thinking.</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;">Highly appreciate in feedback about this.</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><br class=""></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);">This currently is not in a time frame or meant as base for a proposal,</div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><br class=""></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 13px;"><span class="" style="-webkit-font-kerning: none;"></span><br class=""></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;">Kind Regards</span></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; -webkit-text-stroke-color: rgb(0, 0, 0);"><span class="" style="-webkit-font-kerning: none;">Tedvg</span></div></div></blockquote></div></div></blockquote></div><div class="" style="-webkit-text-stroke-width: initial; margin: 0px; line-height: normal; font-family: 'Arial Black'; -webkit-text-stroke-color: rgb(0, 0, 0);"></div></div></body></html>