[swift-dev] [RFC] UnsafeBytePointer API for In-Memory Layout
jordan_rose at apple.com
Thu May 12 21:32:12 CDT 2016
> On May 12, 2016, at 18:34, Andrew Trick <atrick at apple.com> wrote:
>> - On the flip side, I think we do need to preserve the ability to reference-cast in order to send Objective-C messages, at least for now. I don’t know how I want to expose that to users, though. (In general it’s probably worth seeing how unsafeBitCast is used in the wild and what we’d recommend instead.)
> Does ``X as Y`` fail for some reason? We have unchecked versions of ``X as Y`` for performance reasons: ``unsafeDowncast`` and ``_unsafeReferenceCast``.
The particular case I’m thinking about is where we reinterpret an AnyObject as an @objc protocol because we don’t know the dynamic type we would need to add a method to. This doesn’t happen much, and maybe we just say sending arbitrary messages requires an ObjC-side workaround. Or we commit to ‘_unsafeReferenceCast’ and de-underscore it.
(_unsafeReferenceCast is probably a better choice for StdlibUnittest, which is where I used this.)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-dev