|
|
|
|
|
by slavapestov
2315 days ago
|
|
You're right that in general an AOT compiler cannot solve this problem. Swift does specialize generic functions within a module. Across module boundaries, you can declare a function with the `@inlinable` attribute, which makes its body available as part of the module's binary interface. Of course this hinders future evolution of the function -- you can swap in a more efficient implementation of an algorithm for instance, but you have to contend with existing binaries that compiled an older version of the function. The standard library makes extensive use of `@inlinable` for algorithms on generic collection protocols and so on. |
|