Using private attribute @_implements

Hi, Swift forum!

During a recent discussion about forwarding protocol conformances, I happened to suggest an attribute that already seems to exist, in almost the exact same way I suggested :slight_smile: That is, @_implements

it got me thinking: I already have quite a few use cases for this. But, I have a question:

Being an underscored "private" attribute, it can obviously be renamed, change semantics or otherwise change in a source-breaking way in the future. However, will the emitted compiled code, be ABI-stable? Can I use this (given that I am willing to keep call sites up to date with any changes) in my shipped code, and expect it to work on newer versions of the OS, with a future version of Swift bundled with the system?

1 Like

Good question, I would also love to see a clarification on @_exported.

Maybe @Douglas_Gregor or @jrose can answer?

I'm not working on Swift these days, but the baseline rule is "no, using something underscored means your compiled program might already be broken" and that extends to "might work now but break in the future". There are some exceptions to this, with @_exported and @_cdecl being among them—these are attributes that individuals who work on the compiler have publicly made some guarantees about—but I'm not sure if @_implements is in that bucket. It probably works the way you describe, but I don't know myself, and so without a guarantee I'd be hesitant to use it.

1 Like

At the very least, if the attribute becomes official in the future, it's spelling will change. We sometimes retain compatibility with the old underscored spelling, but not always.