[swift-evolution] Does protocol support add to an object's size?

Daryle Walker darylew at mac.com
Mon Apr 3 18:48:19 CDT 2017

> On Apr 3, 2017, at 4:33 PM, Jordan Rose <jordan_rose at apple.com> wrote:
>> On Mar 31, 2017, at 09:39, Joe Groff via swift-evolution <swift-evolution at swift.org> wrote:
>> Protocol conformances are a distinct runtime object from the type itself. There's never any direct record of the conformance in a type's own metadata or instances. This is what allows conformances to be added externally by extensions from other modules.
> At the same time, you are not allowed to assume anything about the layout of structs defined in Swift today. If the compiler wanted to insert the name of the type between every member, it would be permitted to. Please do not assume two structs that look "the same" are laid out the same; if you need to care about in-memory layout, define the struct in C.

As I said in the original post:

> I want to maintain the stride of an array being the total count times the stride of the element, which would complicate nominal arrays if adding protocols to one breaks that. 

This is for built-in arrays, which we don’t have yet. I want to make sure that enforcing “no padding outside the inner non-array type” won’t affect doing “cool Swift things” with the type. This question is mainly aimed towards Swift compiler implementors.

Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170403/049681cf/attachment.html>

More information about the swift-evolution mailing list