Joseph MItzen 251 Posted September 5, 2019 On 8/29/2019 at 9:24 AM, Stefan Glienke said: +1000 And then also introduce proper namespacing and ways to alias things (not only non generic types) at the consuming side (for example) Nobody bring this up with Rudy. I watched him argue voraciously in the distant past that namespace collision with imported units was a feature of the language and there shouldn't even be a warning because it's a feature. He couldn't recall who called it a feature or why, but that didn't shake his conviction in the least. 😭 Share this post Link to post
Joseph MItzen 251 Posted September 6, 2019 On 8/30/2019 at 10:50 AM, Arnaud Bouchez said: Most dev people outside this forum would argue, paraphrasing @Dalija Prasnikar, that 'Delphi is a relic of another time and another coding practices: for instance, there is no GC !'. Php adepts would argue that writing $this->foo is much cleaner/safer than what Delphi (and other languages) do about properties. Well, maybe we should listen to what all those people have to say too. I'm sure there is a lot to learn from many different languages. 1 Share this post Link to post
Joseph MItzen 251 Posted September 6, 2019 (edited) On 8/30/2019 at 10:50 AM, Arnaud Bouchez said: Most dev people outside this forum would argue, paraphrasing @Dalija Prasnikar, that 'Delphi is a relic of another time and another coding practices: for instance, there is no GC !'. Php adepts would argue that writing $this->foo is much cleaner/safer than what Delphi (and other languages) do about properties. On 8/30/2019 at 11:25 AM, Dalija Prasnikar said: We are not discussing other languages here. 'with' is the problem within language itself. Hmmm.... maybe you're both right! I think we need to be discussing other languages here because I can't recall a mainstream language with a "with" statement that does what Delphi's does (Python has a "with" keyword but for a different purpose). So perhaps the question should be asked... how do other languages address this problem? Joe Gregorio of Google once gave a talk in which he stated that design patterns were "language smell". He stated that when the same code is written over and over that's where a feature is needed. He talked about the lack of design patterns in Python and other languages like LISP and then went through how features like first class functions in those languages removed the need for the classic design patterns. Perhaps Delphi's "with" points to language smell and we can look at what features languages without that smell have that eliminate it. Why are people using with? To avoid writing code like this: someBigThing.x := 7; someBigThing.y := 8; someBigThing.z := 9; No one wants to write "someBigThing" over and over. We also see code in Delphi where an object is initialized, then lots of parameters are set one by one (creating a temptation to use "with") and then finally an "execute" method or similar is called. I once dubbed this "the Delphi pattern" and then discovered that it's also a problem/pattern in Java and they have a name for it. Unfortunately, I can't recall it right now. 😞 But how is this dealt with in languages other than Delphi and Java? It turns out there is a language feature which eliminates this pattern.... named parameters. The code above can become Quote someBigThing.set(x=7, y=8, z=9); No ambiguity of the with statement, yet no redundancy of omitting it either! The "Delphi pattern" for object initialization can disappear too into one line of code. Quote someBigThing := SomeClass.Create(server="server.com", port="8080", asynchronous=True, timeout=60) If Delphi introduced named arguments the with statement could be eliminated, removing the dangers, while at the same time preserving the benefits and brevity it granted. A simple fix that makes everyone happy and incidentally provides one of the modern language features needed to design some beautiful APIs. The funny thing is that the language actually does have named parameters, but only under very specific circumstances.... https://stackoverflow.com/questions/885942/named-optional-parameters-in-delphi Trivia note: The above is the only Delphi-related Stack Overflow question without a reply from David Heffernan. Edited September 6, 2019 by Joseph MItzen 2 Share this post Link to post
David Heffernan 2345 Posted September 6, 2019 Dude, before my time. Also, how we miss Rob Kennedy from the Delphi world. 1 Share this post Link to post
Ian Branch 127 Posted September 6, 2019 Hi Team, As a simpleton in the Dephi language world I find 'with' handy for single level application. I did try it with nested withs at one stage and ended up in some angst so I don't do nested with anymore. Just my 2c worth. Ian Share this post Link to post