[swift-evolution] Pitch: Cross-module inlining and specialization
spestov at apple.com
Mon Oct 2 16:23:11 CDT 2017
> On Oct 2, 2017, at 2:20 PM, Greg Parker <gparker at apple.com> wrote:
>> On Oct 2, 2017, at 1:31 PM, Slava Pestov via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> inlinable declarations can only reference other public declarations. This is because they can be emitted into the client binary, and are therefore limited to referencing symbols that the client binary can reference.
> Private @inlinable functions are useful. For example, you might want a helper function to be inlined into a public @inlinable function for performance, but you don't want that helper function to be called by outside clients directly.
> The restriction would then be "inlinable declarations can only reference other public declarations and other @inlinable non-public declarations". This relaxation would have no affect on ABI: only @inlinable things could be inlined, and only public things could be ultimately referenced by inlined things.
> Having said that, it should be fine to use "public @inlinable only" for now and consider relaxing the restriction later.
That’s what @_versioned is currently for. You can define a function as @_versioned @_inlineable and reference it from other public inlinable functions, without making it visible to AST-level lookup.
While I would prefer to punt formalizing this to a future proposal, we can still design the correct spelling and behavior of @_versioned here (I’m pretty sure the current attribute isn’t it).
> Greg Parker gparker at apple.com <mailto:gparker at apple.com> Runtime Wrangler
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution