> Am 15.02.2022 um 15:10 schrieb Derek Fawcus > <dfawcus+lists-gnustep-disc...@employees.org>: > > I don't know about the level of changes needed in GCC, or about the > possibility of using an objC preprocessor, but it was possible to > build and deploy ARC using (including __weak references) code to 10.6.8. > > As I recall one had to build against the 10.7 SDK, and then add an > extra package for the __weak support. > > So in theory one could do something similar regarding the libobjc1 code. > > DF > > https://stackoverflow.com/questions/7696201/how-to-deploy-to-snow-leopard-with-arc-enabled > https://www.mikeash.com/pyblog/introducing-plweakcompatibility.html > <https://www.mikeash.com/pyblog/introducing-plweakcompatibility.html>
Interesting. And I still wonder why ARC seems to need any library support. In my understanding (which is certainly wrong) ARC is automatic reference counting. Done by a static analysis of the source code. Done during compile time and not during run time where the libs/frameworks would play a role. This is the reason why I proposed to think about a preprocessor for standard-gcc to handle these rules and pass everything unchanged. AFAIR the most important memory management rules of ObjC 1.0 are: -alloc and -copy* and -retain return a retained object which must be released before returning from a method. Objects returned by a method must be (explicitly or implicitly) retained+autoreleased. Objects assigned to persistent store (instance vars) must be retained and the previous value must be released before. This is (not necessarily) usually wrapped by a setter method. These are not extraordinarily complex so I also tend to think that training is not well enough if programmers struggle with them. But they obviously do. Hm. Just some thought: is anyone is looking for a master's or PhD-thesis: would it be possible to statically analyse retain/release/autorelease code to locate memory leaks which come from not following these rules? BTW note: Linux kernel also has trouble with non-automatic reference counting. retain/release are called get and put there. E.g.: https://patchwork.kernel.org/project/linux-omap/patch/20211014085719.23739-1-wanjiab...@vivo.com/#24665947 But they don't have the nice autorelease-pool and the rule that most methods return autoreleased objects and caller must retain them (they often return retained object and caller must put them)... --hns