top | item 22295818

(no title)

byt143 | 6 years ago

Why can't you just have the higher level representation of the code available and just recompile everything?

discuss

order

slavapestov|6 years ago

Basically, because Swift has to support separate compilation of shared libraries.

The @inlinable attribute is in fact implemented by serializing the high-level IR of a function as part of the module's interface; but doing this for all functions would be a non-starter, because it would place unacceptable restrictions on binary framework evolution.

You can think of @inlinable as being somewhat similar to defining a function in a C header file. Unlike C++ templates, Swift generics don't require all definitions to be available at compile time, because dictionary passing is used to compile generic code when monomorphization cannot be performed.