[swift-dev] What can you change in a fixed-contents struct?

2017-09-05 Thread Jordan Rose via swift-dev
Hey, all. In preparation for the several proposals we have to come this year, I cleaned up docs/LibraryEvolution.rst a little bit based on what's changed in Swift 4. This is mostly just mentioning things about generic subscripts, but there is one issu

Re: [swift-dev] What can you change in a fixed-contents struct?

2017-09-05 Thread David Zarzycki via swift-dev
Hi Jordan, Thanks for thinking about this. For whatever it may be worth, I’m concerned about 1) the ability to reorder declarations and 2) the “either/or” nature of this proposal. First, reordering: The ability to reorder declarations is deeply ingrained into the subconsciousness of Swift prog

Re: [swift-dev] What can you change in a fixed-contents struct?

2017-09-05 Thread Thomas Roughton via swift-dev
Hi Jordan and David, Reading this from a user’s perspective, I’d be very much in favour of something like the @abi annotation. The core issue I see with the ‘allow renaming’ approach is that users coming to Swift from other languages will do so with the expectation that ordering is significant

Re: [swift-dev] What can you change in a fixed-contents struct?

2017-09-05 Thread Slava Pestov via swift-dev
> On Sep 5, 2017, at 2:48 PM, Thomas Roughton via swift-dev > wrote: > > Having an explicit @abi annotation could also go some way to addressing the > issue of manual layout with structs. I’m primarily thinking of graphics > contexts, wherein you need to declare e.g. a struct with vertex layo

Re: [swift-dev] What can you change in a fixed-contents struct?

2017-09-05 Thread Jordan Rose via swift-dev
> On Sep 5, 2017, at 15:08, Slava Pestov via swift-dev > wrote: > >> >> On Sep 5, 2017, at 2:48 PM, Thomas Roughton via swift-dev >> mailto:swift-dev@swift.org>> wrote: >> >> Having an explicit @abi annotation could also go some way to addressing the >> issue of manual layout with structs.

Re: [swift-dev] What can you change in a fixed-contents struct?

2017-09-05 Thread Slava Pestov via swift-dev
> On Sep 5, 2017, at 1:01 PM, David Zarzycki via swift-dev > wrote: > > Hi Jordan, > > Thanks for thinking about this. For whatever it may be worth, I’m concerned > about 1) the ability to reorder declarations and 2) the “either/or” nature of > this proposal. > > First, reordering: The abil

Re: [swift-dev] What can you change in a fixed-contents struct?

2017-09-05 Thread David Zarzycki via swift-dev
> On Sep 5, 2017, at 18:14, Slava Pestov wrote: > > >> On Sep 5, 2017, at 1:01 PM, David Zarzycki via swift-dev >> wrote: >> >> Hi Jordan, >> >> Thanks for thinking about this. For whatever it may be worth, I’m concerned >> about 1) the ability to reorder declarations and 2) the “either/o

Re: [swift-dev] What can you change in a fixed-contents struct?

2017-09-05 Thread Greg Parker via swift-dev
> On Sep 5, 2017, at 11:59 AM, Jordan Rose via swift-dev > wrote: > > Hey, all. In preparation for the several proposals we have to come this year, > I cleaned up docs/LibraryEvolution.rst > a little bit based on what's > changed in Swift 4. This i

Re: [swift-dev] What can you change in a fixed-contents struct?

2017-09-05 Thread Jordan Rose via swift-dev
> On Sep 5, 2017, at 15:52, Greg Parker wrote: > > >> On Sep 5, 2017, at 11:59 AM, Jordan Rose via swift-dev > > wrote: >> >> Hey, all. In preparation for the several proposals we have to come this >> year, I cleaned up docs/LibraryEvolution.rst >>

Re: [swift-dev] What can you change in a fixed-contents struct?

2017-09-05 Thread Jordan Rose via swift-dev
Hm. This is definitely an option, but I don't think it's really an acceptable user experience. This feels like it'll drive people all the way to declaring their types in C because Swift makes it too hard. We do expect to have a tool to diff old and new modules at some point, but we could do som

Re: [swift-dev] What can you change in a fixed-contents struct?

2017-09-05 Thread Nevin Brackett-Rozinsky via swift-dev
On Tue, Sep 5, 2017 at 6:08 PM, Slava Pestov via swift-dev < swift-dev@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 t

Re: [swift-dev] What can you change in a fixed-contents struct?

2017-09-05 Thread Slava Pestov via swift-dev
> On Sep 5, 2017, at 6:37 PM, Nevin Brackett-Rozinsky via swift-dev > wrote: > > On Tue, Sep 5, 2017 at 6:08 PM, Slava Pestov via swift-dev > mailto:swift-dev@swift.org>> wrote: > We expect that “define your struct in C” is still the way to go for layout > compatibility with other languages a

Re: [swift-dev] What can you change in a fixed-contents struct?

2017-09-05 Thread Andrew Trick via swift-dev
> On Sep 5, 2017, at 5:11 PM, Jordan Rose via swift-dev > wrote: > > Another idea would be to restrict @fixedContents to require that all stored > properties appear contiguously in the struct, possibly even pinned to the top > or bottom, to indicate that order's not completely arbitrary. Agai

Re: [swift-dev] What can you change in a fixed-contents struct?

2017-09-05 Thread John McCall via swift-dev
> On Sep 5, 2017, at 9:41 PM, Slava Pestov via swift-dev > wrote: > > >> On Sep 5, 2017, at 6:37 PM, Nevin Brackett-Rozinsky via swift-dev >> mailto:swift-dev@swift.org>> wrote: >> >> On Tue, Sep 5, 2017 at 6:08 PM, Slava Pestov via swift-dev >> mailto:swift-dev@swift.org>> wrote: >> We exp

Re: [swift-dev] What can you change in a fixed-contents struct?

2017-09-05 Thread John McCall via swift-dev
> On Sep 5, 2017, at 2:58 PM, Jordan Rose wrote: > Hey, all. In preparation for the several proposals we have to come this year, > I cleaned up docs/LibraryEvolution.rst > a little bit based on what's > changed in Swift 4. This is mostly just mentioni

Re: [swift-dev] What can you change in a fixed-contents struct?

2017-09-06 Thread David Zarzycki via swift-dev
Hi Jordan, I really doubt that “belt and suspenders” ABI attributes would drive people to C, but reasonable people can certainly disagree on that. Bertrand, when he was at Apple, used to say that “easy things should be easy, and hard things should be possible”. I think ABI related attributes f

Re: [swift-dev] What can you change in a fixed-contents struct?

2017-09-06 Thread Jordan Rose via swift-dev
> On Sep 5, 2017, at 18:37, Nevin Brackett-Rozinsky via swift-dev > wrote: > > On Tue, Sep 5, 2017 at 6:08 PM, Slava Pestov via swift-dev > mailto:swift-dev@swift.org>> wrote: > We expect that “define your struct in C” is still the way to go for layout > compatibility with other languages an

Re: [swift-dev] What can you change in a fixed-contents struct?

2017-09-06 Thread Jordan Rose via swift-dev
I'd be okay with allowing the ABI attributes to control ordering, but I would definitely not require them on every fixed-contents struct. We hope making a struct fixed-contents isn't something people have to do too often, but we don't want to drop them all the way into "hard" land when they do i

Re: [swift-dev] What can you change in a fixed-contents struct?

2017-09-06 Thread David Zarzycki via swift-dev
Ah, now that I see the CGPoint example, I understand. Thanks! Ya, the “hard” user-experience model I brought up feels wrong for CGPoint, etc. (For non-Apple people, CGPoint is a struct of two doubles on 64-bit machines add two floats on 32-bit machines.) It wasn’t obvious to me from context tha

Re: [swift-dev] What can you change in a fixed-contents struct?

2017-09-06 Thread Jordan Rose via swift-dev
I don't think that's the right way to think about it either. It's purely an optimization tool to say "I won't add anything else to this struct", which means the compiler can avoid indirection when manipulating the struct across module boundaries. We could implement it with dynamic offset symbols

Re: [swift-dev] What can you change in a fixed-contents struct?

2017-09-06 Thread David Zarzycki via swift-dev
I see. Would “@fixedSize” or “@abi(size)” be better names? In other words, the developer promises that whatever size the struct is now, it will be that way forever? Also, wouldn’t the Pair example below require that ‘A’ also be @fixedContents? Otherwise what does @fixedContents mean if the elem

Re: [swift-dev] What can you change in a fixed-contents struct?

2017-09-06 Thread Jordan Rose via swift-dev
That's exactly why neither of those names are correct. The annotation we're describing here means "the stored properties of this struct will not change, please optimize". That gives us the actual fully-specified layout optimizations when the contents happen to be non-generic and similarly annota

Re: [swift-dev] What can you change in a fixed-contents struct?

2017-09-06 Thread David Zarzycki via swift-dev
Hi Jordan, Okay, I just read the Library Evolution section about @fixedContents. Ya, the name of this attribute is difficult due to the collection of goals and subtle implications. I worry that others will find it difficult too, no matter what the name. :-/ I skimmed the rest of the document l

Re: [swift-dev] What can you change in a fixed-contents struct?

2017-09-06 Thread Slava Pestov via swift-dev
> On Sep 6, 2017, at 11:09 AM, David Zarzycki via swift-dev > wrote: > > I see. Would “@fixedSize” or “@abi(size)” be better names? In other words, > the developer promises that whatever size the struct is now, it will be that > way forever? > > Also, wouldn’t the Pair example below require

Re: [swift-dev] What can you change in a fixed-contents struct?

2017-09-06 Thread Brent Royal-Gordon via swift-dev
> On Sep 5, 2017, at 11:59 AM, Jordan Rose via swift-dev > wrote: > > Now, we don't plan to stick to C's layout for structs, even fixed-contents > structs. We'd really like users to not worry about manually packing things > into trailing alignment space. But we still need a way to lay out fiel

Re: [swift-dev] What can you change in a fixed-contents struct?

2017-09-06 Thread Slava Pestov via swift-dev
> On Sep 6, 2017, at 7:57 PM, Brent Royal-Gordon via swift-dev > wrote: > >> On Sep 5, 2017, at 11:59 AM, Jordan Rose via swift-dev > > wrote: >> >> Now, we don't plan to stick to C's layout for structs, even fixed-contents >> structs. We'd really like users to not

Re: [swift-dev] What can you change in a fixed-contents struct?

2017-09-09 Thread Brent Royal-Gordon via swift-dev
> On Sep 6, 2017, at 9:52 PM, Slava Pestov wrote: > >> On Sep 6, 2017, at 7:57 PM, Brent Royal-Gordon via swift-dev >> mailto:swift-dev@swift.org>> wrote: >> >> This is going against the grain, but I think we should order by name and >> therefore allow reordering, but not renaming. If an API i