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

Jean-Daniel Dupas mailing at xenonium.com
Thu Jun 9 14:04:50 CDT 2016

> Le 9 juin 2016 à 01:41, Alexander Momchilov via swift-evolution <swift-evolution at swift.org> a écrit :
> 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

I can’t see how it would speed up app launch time. You still all have to allocate and init all UI objects, especially as they are opaque objects and can’t be precomputed.

> 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
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160609/d9a46cb9/attachment.html>

More information about the swift-evolution mailing list