[swift-evolution] Proposal: allow arbitrary compile-time code execution

Chris Lattner clattner at apple.com
Mon Feb 8 13:13:38 CST 2016

> On Feb 7, 2016, at 8:29 PM, Steve Richey via swift-evolution <swift-evolution at swift.org> wrote:
> It is not uncommon to want to run code at build time. Xcode solves this need by allowing "Build Phases", which are often shell scripts which handle compile-time tasks.
> It may be beneficial to Swift developers, especially those who are not programming on platforms supported by Xcode, to handle compile-time tasks in a powerful and expressive language with which they are already familiar: Swift!
> In short, I propose the addition of a `#run` expression that allows the execution of code at compile time. This syntax and concept are borrowed from the programming language Jai (https://sites.google.com/site/jailanguageprimer/#TOC-Arbitrary-Compile-Time-Code-Execution <https://sites.google.com/site/jailanguageprimer/#TOC-Arbitrary-Compile-Time-Code-Execution>) but the syntax fits nicely with other special expression syntax in Swift such as `#available`, `#selector`, `#file`, and so on.

Something like this would definitely be interesting to build out.  We should investigate it post-Swift 3 in the context of a hygienic macro system.


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

More information about the swift-evolution mailing list