[swift-evolution] [Proposal] Add support for compile-time function execution

Alexander Momchilov alexandermomchilov at gmail.com
Wed Jun 8 18:41:18 CDT 2016


Preface: I know this is likely a large undertaking to implement, but I think it's worth it.

In addition to the typical compiler optimization of constant math expressions, some languages (such as D and C++) have support for running arbitrary functions at compile time <https://en.wikipedia.org/wiki/Compile_time_function_execution> (with some constraints).

I see many advantages of this:
On iOS/OS X: it could precompute the UI and app initialization logic (wherever possible) to speed app load times
It can significantly speed up the initialization of applications with large static properties. E.g. large constant Dictionaries could be precomputed.
You could keep complex math expressions (including custom functions) in their unevaluated form, without the pressure to precompute them elsewhere and hardcode in the result.
Dynamic programming: expensive look-up tables could be precomputed. These wouldn't necessarily be large in size, but if their elements are especially expensive to compute, there would be a huge advantage to precomputing them.

What do you guys think? Can you think of any other useful applications? Would it be worth the implementation effort?

- Regards,
        Alexander Momchilov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160608/edb5feb8/attachment.html>


More information about the swift-evolution mailing list