<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"><channel><title>mikeash.com pyblog/friday-qa-2012-05-18-a-tour-of-plweakcompatibility-part-i.html comments</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2012-05-18-a-tour-of-plweakcompatibility-part-i.html#comments</link><description>mikeash.com Recent Comments</description><lastBuildDate>Sun, 12 Apr 2026 02:28:42 GMT</lastBuildDate><generator>PyRSS2Gen-1.0.0</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Vladimir Pouzanov - 2012-12-30 19:24:01</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2012-05-18-a-tour-of-plweakcompatibility-part-i.html#comments</link><description>I wonder if it's possible to make your functions trampoline the same way as dyld lazy symbols (stub_helper/symbolstub1/lazy_symbol -like). Wouldn't that be much more efficient even than dispatch_once?</description><guid isPermaLink="true">43f8d4661270784b85871dacfa712024</guid><pubDate>Sun, 30 Dec 2012 19:24:01 GMT</pubDate></item><item><title>mikeash - 2012-05-19 13:53:48</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2012-05-18-a-tour-of-plweakcompatibility-part-i.html#comments</link><description>A big goal with this was to make it as simple as possible to incorporate the files into an existing ARC project. By making the files ARC-compatible, this eliminates the need to fiddle with any special compiler flags. It's not a big deal, but the less work the better.
&lt;br /&gt;
&lt;br /&gt;I like your idea with the function pointer, but that would require every entry point to have basically two definitions, one that does the basic fetch-once-and-call, and then a second one that does the actual work. Most of the functions don't directly call a PL function, but do a bit of work and then call through to another function. It's certainly doable, but it seems like a bit of a toss-up to me.</description><guid isPermaLink="true">e9e7268259dfd204c5e3d1768cd846db</guid><pubDate>Sat, 19 May 2012 13:53:48 GMT</pubDate></item><item><title>Jonathon Mah - 2012-05-18 22:31:37</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2012-05-18-a-tour-of-plweakcompatibility-part-i.html#comments</link><description>With regard to the latter, my suggestion only applies to your first snippet, unless the own-implementation versions were broken out into separate functions, I suppose. Perhaps a block could be used instead of a separate top-level function...</description><guid isPermaLink="true">5db6ce9402f61d6f50d7dec02667315a</guid><pubDate>Fri, 18 May 2012 22:31:37 GMT</pubDate></item><item><title>Jonathon Mah - 2012-05-18 22:07:32</title><link>http://www.mikeash.com/?page=pyblog/friday-qa-2012-05-18-a-tour-of-plweakcompatibility-part-i.html#comments</link><description>Hi Mike,
&lt;br /&gt;
&lt;br /&gt;Thanks, this looks really interesting! Why do you a typdef (PLObjectPtr) instead of compiling with -fno-objc-arc? (You can force an error like so:)
&lt;br /&gt;
&lt;br /&gt;&lt;code&gt;#if __has_feature(objc_arc)
&lt;br /&gt;#error This file must not be compiled with ARC blah blah
&lt;br /&gt;#endif&lt;/code&gt;
&lt;br /&gt;
&lt;br /&gt;Also, in my mind it would be cleaner to do the function stuff like this:
&lt;br /&gt;
&lt;br /&gt;&lt;code&gt;dispatch_once(..., ^{
&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;fptr = dlsym(RTLD_NEXT, "objc_loadWeakRetained") ? : PLLoadWeakRetained;
&lt;br /&gt;});&lt;/code&gt;
&lt;br /&gt;
&lt;br /&gt;(ternary is up to you; use an if if you like). Then the non-once code simply calls &lt;code&gt;fptr&lt;/code&gt; each time.</description><guid isPermaLink="true">500189bfb0a02e7e2ad03135a9d61696</guid><pubDate>Fri, 18 May 2012 22:07:32 GMT</pubDate></item></channel></rss>
