4 ms·
Specifically "complex runtime state inspection (say, to support breaking reference cycles)". There's no safe way to walk the object graph to break reference cy
by flatline3 14y ago
Specifically "complex runtime state inspection (say, to support breaking reference cycles)".
There's no safe way to walk the object graph to break reference cycles, despite Apple implementing both ivar indirection (to solve the fragile base class problem), and implementing what should be self-describable block structures.
Information such as whether a particular captured variable/ivar is a weak or strong reference would have been very simple and cheap to include in the runtime metadata, but was -- like many other things -- not included.
In another comment in this thread I described the difference between Apple's runtime/language design and everyone else's:
This sort of hackish minimalism is the polar opposite of the careful considered and long-term focused design that Microsoft (and even Sun) applied to the core of their platform. Compare the completeness (and longevity) of the JVM Virtual Machine specification to the ObjC runtime. Over roughly the same amount of time, Apple has had to introduce complete ABI-breaking fundamental changes of to their runtime to implement extremely basic language enhancements. In contract, the JVM specification has not, to my recollection, been broken once over the course of 20 years. Additions have always been forward-compatible.
- comex 14y agoThe weakIvarLayout field seems to do exactly what you're saying for ivars, though there is no equivalent for blocks. (Whether you can [safely] do it anyway depends, I suppose, on whether you're willing to inspect machine code; it's not that hard, though the suggestion does nothing to disprove your claim of hackish minimalism.)
- flatline3 14y agoUnfortunately, as I recall, the meaning of weakIvarLayout is different depending on whether the code is compiled for ARC, non-ARC, or non-ARC GC/GC-optional. Unfortunately I don't remember the specifics off-hand. Also, yes, runtime machine code inspection is a ... possibility ... :) It's not that 'hard', but it's certainly harder than clean metadata, and it means maintaining individual introspection code for all supported architectures.