Hi, On Thu, 17 Oct 2024, Michael Van Canneyt via fpc-pascal wrote:
> By contrast, Pascal is not designed with GC in mind. > You'd need to redesign the language. > > If you do that, you can throw away all existing code if you introduce GC, > because the two concepts do not merge easily. > > Embarcadero tried it in Delphi, and they failed. Not surprisingly, > they removed again all automatic memory management. Maybe it was mentioned in the thread, I just glanced through it, but how about ARC (Automatic Reference Counting), Objective C style? To be honest, I really liked that, and we already have it kind of in place for strings, even temporary strings and maybe even temporary arrays created inside a function. We'd just need to extend it for a bunch of other things, I suppose. Manual FreeAndNil() is the ugliest part of Object Pascal for me for sure... OTOH, for Object Pascal you might end up with RAII in this case, instead of ARC, because how how the language works. I did not like it that much in C++, but maybe because modern C++ syntax is properly horrid... But anyway, that concept replaces GC for a majority of use cases, and I really liked it for the couple of years I've been doing iOS stuff. But of course Apple adopted it for all the underlying classes too, which points back to the fact, that modern languages are usually a thin wrappers around some library concept, and if your library API is as full of legacy and as inherently messy as ours, there's little you can do. For once, I'd be really glad if a bunch of the containers would be Thread-Safe by default, like TList and things, and they aren't, because they're based on almost 3 decade old Delphi concepts, when multithreading wasn't as big of a deal as these days. No amount of "lets add GC" would fix this. (And I know we have thread-safe alternatives, but they aren't used everywhere and consistently. So when using a bunch of libraries, you still end up managing thread-safety by hand...) Charlie _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal