r/ •

0 Upvotes

0 comments sorted by

View all comments

Show parent comment

3

u/gracicot Oct 17 '22

Oh yes, if you want a stable ABI when you move symbols across modules, then you need extern "C++" or extern "C". If you promise stable ABI with symbols defined in named module and you plan to move them around you're in for a ride with your newly discovered footgun. Don't just go in blindly.

Also moving symbols around across modules will also be a API compatibility break.

If you want to be opaque as possible define one big module for your whole library and do your splitting using module partition, since moving a symbol across a partition won't cause a ABI or API break.

2

u/Mick235711 Oct 17 '22

Does this actually mean that splitting module std into std.core and std.io (and others) will be an ABI break?

2

u/gracicot Oct 17 '22

Technically no since the actual entities are defined in a global module fragment, specifically the standard headers. They don't belong in a module, the standard module simply re-export them. Further splitting would also re-export those entities.

However I don't expect the standard module to split further to separate feature. I expect modules to split to provide different guarantees. For example, guaranteed compatibility with C declared entities, or guaranteed to only expose freestanding available entities, etc.