[swift-dev] What can you change in a fixed-contents struct?
spestov at apple.com
Tue Sep 5 20:40:28 CDT 2017
> On Sep 5, 2017, at 6:37 PM, Nevin Brackett-Rozinsky via swift-dev <swift-dev at swift.org> wrote:
> On Tue, Sep 5, 2017 at 6:08 PM, Slava Pestov via swift-dev <swift-dev at swift.org <mailto:swift-dev at swift.org>> wrote:
> We expect that “define your struct in C” is still the way to go for layout compatibility with other languages and systems.
> Are there plans (however tentative) to eventually make it possible to specify the exact memory layout of a struct in Swift?
It’s not clear what ‘exact memory layout’ means. In C, you don’t get to specify the exact layout either — there are rules around alignment and padding and some non-standard attributes for controlling them, but that’s not quite the same thing.
> It seems like something we will have to tackle in order for Swift to become a serious systems-level programming language.
We do plan on documenting Swift’s struct (and tuple) layout algorithms as part of ABI stability, because we will need to freeze them (at least for types that cross resilience boundaries) to actually have a stable ABI. So you could, with knowledge of the layout algorithm, define a struct and make assumptions about it’s layout in memory, based on your knowledge of the algorithm as it is implemented in the version of Swift you are using. Not quite the same as explicitly specifying a layout, though.
> swift-dev mailing list
> swift-dev at swift.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-dev