<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=""><div class=""><br class=""></div><div class=""><blockquote type="cite" class="">What it does is allow developers to extend the language to do things that it doesn't support. </blockquote></div><div class=""><br class=""></div><div class=""><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="-webkit-font-kerning: none;" class="">Hitting boundaries... or so it seems... This is very interesting. </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="-webkit-font-kerning: none;" class="">In spite of its very modern approach, </span><span style="-webkit-text-stroke-width: initial;" class="">wether we like it or not, Swift is </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="-webkit-text-stroke-width: initial;" class="">still a </span><span style="-webkit-text-stroke-width: initial;" class="">conventional Hard Coded Statical Programming Language,</span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class=""> (here further in this text referred to as HCSPL) </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">which means that, like in C++ or C# etc. its language </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">elements are essentially predefined, "fixed", and that </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">it is therefore a daunting task to make the language </span><span style="-webkit-text-stroke-width: initial;" class="">as </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="-webkit-text-stroke-width: initial;" class="">versatile as possible and to satisfy everyone's requirements, </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="-webkit-text-stroke-width: initial;" class="">We can see that every day in </span><span style="-webkit-text-stroke-width: initial;" class="">swift-evolution and for that matter </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="-webkit-text-stroke-width: initial;" class="">all other HCSPL (C#, C++, Python, ObjC etc) related forums.</span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial; min-height: 13px;" class=""><span style="font-kerning: none" class=""></span><br class=""></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">HCSPL are in a sense a traditional compromise to "The Machine” </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">and enables us -within the limitations </span><span style="-webkit-text-stroke-width: initial;" class=""> of our current state of main </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="-webkit-text-stroke-width: initial;" class="">stream technology- to make highly optimised fast running compiled applications. </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">That we know is the virtue of hard coded static languages. </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">"The Machine" however gets more advanced and faster day by day </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">thereby diminishing the need for HCSPL in its course. </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial; min-height: 13px;" class=""><span style="font-kerning: none" class=""></span><br class=""></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">However, (as far as I know) , due to the nature of HCSPL, like Swift, </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">there is no (direct and supported and convenient) </span><span style="-webkit-text-stroke-width: initial;" class="">way supporting </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="-webkit-text-stroke-width: initial;" class="">meta-programming facilities, e.g. to generate define objects (classes), </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="-webkit-text-stroke-width: initial;" class="">and its instances on the fly, that is, at run time.</span><span style="-webkit-text-stroke-width: initial;" class=""> </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial; min-height: 13px;" class=""><span style="font-kerning: none" class=""></span><br class=""></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">In most cases, one can live with this HCSPL "compromise", especially with Swift, </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">which is very flexible and offers </span><span style="-webkit-text-stroke-width: initial;" class="">many convenient ways to solve a wide spectrum </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="-webkit-text-stroke-width: initial;" class="">of programming challenges. However, one could think of many </span><span style="-webkit-text-stroke-width: initial;" class="">applications like</span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="-webkit-text-stroke-width: initial;" class=""> in AI where applications can improve and extend themselves, learning to adjust </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="-webkit-text-stroke-width: initial;" class="">and adapt to </span><span style="-webkit-text-stroke-width: initial;" class="">their environment, thereby altering and tuning its performance, </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="-webkit-text-stroke-width: initial;" class="">like our brains do...naturally. </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="-webkit-text-stroke-width: initial;" class="">In contrast, a</span><span style="-webkit-text-stroke-width: initial;" class=""> HCSPL forces one to match one's problem solving to the language </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="-webkit-text-stroke-width: initial;" class="">elements that are available in the HCSPL. </span><span style="-webkit-text-stroke-width: initial;" class="">In a sense it's like having a big box </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="-webkit-text-stroke-width: initial;" class="">with Lego bricks, that is predefined discrete elements, which allow one to build things </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">with it, however it still remains limited as Lego. </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">This is not the case with a dynamic language like Smalltalk.</span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial; min-height: 13px;" class=""><span style="font-kerning: none" class=""></span><br class=""></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">Since ca 1980 I have a high interest in Smalltalk (and other OOP dynamic</span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">programming languages too). </span><span style="-webkit-text-stroke-width: initial;" class="">Some would argue that Smalltalk is a </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="-webkit-text-stroke-width: initial;" class="">programming language, but take a closer </span><span style="-webkit-text-stroke-width: initial;" class="">look, (e.g. with Pharo).</span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">It is just a relatively small set of mainly syntactic rules defining the </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">environment </span><span style="-webkit-text-stroke-width: initial; -webkit-font-kerning: none;" class="">wherein the Smalltalk </span><span style="-webkit-text-stroke-width: initial;" class="">system lives (almost literally) as a </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="-webkit-text-stroke-width: initial;" class="">dynamic object hierarchy, </span><span style="-webkit-text-stroke-width: initial;" class="">were everything is an object, which as we </span><span style="-webkit-text-stroke-width: initial;" class="">know </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="-webkit-text-stroke-width: initial;" class="">is a completely different approach </span><span style="-webkit-text-stroke-width: initial;" class="">compared to HCSPLs.</span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial; min-height: 13px;" class=""><span style="font-kerning: none" class=""></span><br class=""></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">Before Swift had arrived, my hope was that the successor of Objective C </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">would be Smalltalk, or at least Smalltalk </span><span style="-webkit-text-stroke-width: initial;" class=""> as a breeding environment for </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="-webkit-text-stroke-width: initial;" class="">developing macOS, iOS, tvOS and watchOS applications. In this role it would then</span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">be desirable that the apps thus produced are "closed apps" so to speak, that is that </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">the development environment </span><span style="-webkit-text-stroke-width: initial;" class="">is not available to the end-user.</span><span style="-webkit-text-stroke-width: initial;" class=""> </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">The thought of a e.g. "new Xcode/Smalltalk" being the next Apple development </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">environment seemed reasonable, </span><span style="-webkit-text-stroke-width: initial;" class="">also because ObjectiveC had features </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="-webkit-text-stroke-width: initial;" class="">inspired by Smalltalk. (as all OOP languages have) </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">Alas, it didn't happen..but I keep dreaming... </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial; min-height: 13px;" class=""><span style="font-kerning: none" class=""></span><br class=""></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">Perhaps out of context, one then might ask how to interface that </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">Xcode/Smalltalk to all those existing </span><span style="-webkit-text-stroke-width: initial;" class="">libraries (Cocoa UIKit etc.) </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="-webkit-text-stroke-width: initial;" class="">This can be done by letting Smalltalk crawl through all API definitions,</span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">generating its own interface classes dynamically. This sounds ambitious </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">but it can be done. Something </span><span style="-webkit-text-stroke-width: initial;" class="">a HCSPL like Swift could never do as it is.</span><span style="-webkit-text-stroke-width: initial;" class=""> </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial; min-height: 13px;" class=""><span style="font-kerning: none" class=""></span><br class=""></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">And now we don't have Smalltalk but instead Swift, not bad at all, currently </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="font-kerning: none" class="">I find it the most advanced HCSPL </span><span style="-webkit-text-stroke-width: initial;" class="">now available. </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="-webkit-text-stroke-width: initial;" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="-webkit-text-stroke-width: initial;" class="">However, my verbose text here could be food for thoughts: </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="-webkit-text-stroke-width: initial;" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="-webkit-text-stroke-width: initial;" class="">Is it possible to have best of (these completely different) both worlds? </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="-webkit-text-stroke-width: initial;" class="">Would it be possible in Swift </span><span style="-webkit-text-stroke-width: initial;" class="">to have facilities to generate objects </span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-color: rgb(0, 0, 0); -webkit-text-stroke-width: initial;" class=""><span style="-webkit-text-stroke-width: initial;" class="">dynamically at runtime? </span><span style="-webkit-text-stroke-width: initial;" class="">and, if desirable, how can such be implemented?</span></div></div><div class=""><span style="font-kerning: none" class=""><br class=""></span></div><div class=""><br class=""></div><div class="">Kind Regards</div><div class="">TedvG</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><blockquote type="cite" class="">On Sep 30, 2016, at 9:40 AM, Jay Abbott <<a href="mailto:jay@abbott.me.uk" class="">jay@abbott.me.uk</a>> wrote:</blockquote></div><div class=""><blockquote type="cite" class=""><br class=""></blockquote></div><div class=""><blockquote type="cite" class="">Robert,</blockquote></div><div class=""><blockquote type="cite" class=""><br class=""></blockquote></div><div class=""><blockquote type="cite" class="">What it does is allow developers to extend the language to do things that it doesn't support. Associated Objects is just a flexible way to allow developers to do that, and that's how I used it in Objective-C, so that's what I thought of in Swift when I found that "I want to do <x> but the language doesn't support it". Maybe there's a completely different way to achieve the same thing - but I just went with what I know.</blockquote></div><div class=""><br class=""></div><div class="">"I want to do <x> but the language doesn't support it” is the whole reason for this list! I want to know what “<x>” is in order to wrap my head around your proposal better. I’m not here to invalidate your work with a slew of criticisms, I’m just trying to understand your proposal by probing you about it.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><blockquote type="cite" class="">So it's difficult to come up with concrete examples of "things a developer might want to do but the language doesn't support" because almost by definition they are unforeseen. I can only enumerate the things I have wanted to do in Obj-C and Swift and how I got around it.</blockquote></div><div class=""><blockquote type="cite" class="">- Dynamically add properties to a class (obc-c) / implement stored properties (swift).</blockquote></div><div class=""><blockquote type="cite" class="">- Add per-instance methods at run-time.</blockquote></div><div class=""><blockquote type="cite" class="">- Perform a function when some other object is deallocated (haven't solved this in Swift yet, but in obj-c associated object deallocation is well-defined so I used that).</blockquote></div><div class=""><blockquote type="cite" class="">- Other unforeseen things…</blockquote></div><div class=""><br class=""></div><div class="">Again, these are features and I want motivations behind them. Why should you be able to dynamically add stored properties and methods to any Swift class? Why should you be able to observe deallocation if deallocation calls are not guaranteed (remember, Objective-C and Swift do not guarantee -dealloc/deinit calls in any order at any time - please don’t assume an RAII-like model because it will lead to memory leaks and malformed code).</div><div class=""><br class=""></div><div class="">I will say: Perhaps if you’re having trouble motivating the inclusion of this feature, you may want to step back and reevaluate its place in the language and why you wanted to write this library in the first place. Often times, I find that really helps get the creative juices flowing. Or, if I can’t come up with anything, it means I go back to step 1 and start over. Proposals can be as much a learning process for us as it is for you.</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><br class=""></blockquote></div><div class=""><blockquote type="cite" class="">So maybe Associated Objects isn't the answer and I should have stated the problem better, instead of jumping to what I thought the answer might be... the problem I want to solve is this:</blockquote></div><div class=""><blockquote type="cite" class=""><br class=""></blockquote></div><div class=""><blockquote type="cite" class="">As a developer I want to do <x> but the language doesn't support it... what helpful thing *can* I use right now that allows me to achieve this? I accept the disclaimer by ticking this box:</blockquote></div><div class=""><blockquote type="cite" class="">[ ] Yes, I understand that I'm not using Swift anymore, but some custom run-time thing that I'm building myself on top of Swift, so if I want type safety I have to implement it, if I want copy-on-write or other optimisations, I have to implement it, and I understand that performance might not be the best too.</blockquote></div><div class=""><blockquote type="cite" class=""><br class=""></blockquote></div><div class=""><br class=""></div><div class="">So from what I’ve gathered you’ve written a library to do this yourself. You have a vision for how you want to use this library. You think that vision is compatible with a language-level change. From my perspective, your job now is to articulate that vision and motivate it to this list. I don’t think associated objects and the other dynamic features you mention are fundamentally incompatible with Swift, I just think the design that I’ve seen so far may not be the best way of going about it and I’m voicing my concerns as much. </div><div class=""><br class=""></div><div class=""><blockquote type="cite" class="">If Swift can provide something to help developers go beyond the abilities the current version, isn't that a good idea?</blockquote></div><div class=""><br class=""></div><div class="">No one disputes this. We just want to see your rationale.</div></blockquote><div class=""><br class=""></div></body></html>