<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">That's actually very complex for types that can't be serialized/"encoded".<br class=""><div class="">
<br class="Apple-interchange-newline"><span style="color: rgb(0, 0, 0); font-family: 'Lucida Grande'; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none;" class="">Félix</span>
</div>

<br class=""><div><blockquote type="cite" class=""><div class="">Le 8 févr. 2016 à 00:12:17, Jarod Long via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; a écrit :</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">+1</div><div class=""><br class=""></div><div class="">I saw the Jai presentation that covered this feature, and it struck me as quite powerful. Simple compile-time asset processing is highly appealing to me -- that would be particularly helpful in the domain of games.</div><div class=""><br class=""></div><div class="">I think this feature has a very high value/complexity ratio.</div><div class=""><br class=""></div><div class="">Jarod</div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Feb 7, 2016, at 20:29, Steve Richey via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class="">

<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" class="">

<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; font-size: 14px; font-family: Calibri, sans-serif;" class="">
<div class="">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.</div>
<div class=""><br class="">
</div>
<div class="">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!</div>
<div class=""><br class="">
</div>
<div class="">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 (<a href="https://sites.google.com/site/jailanguageprimer/#TOC-Arbitrary-Compile-Time-Code-Execution" class="">https://sites.google.com/site/jailanguageprimer/#TOC-Arbitrary-Compile-Time-Code-Execution</a>)
 but the syntax fits nicely with other special expression syntax in Swift such as `#available`, `#selector`, `#file`, and so on.</div>
<div class=""><br class="">
</div>
<div class="">Example:</div>
<div class="">```</div>
<div class="">func myFunction() -&gt; String {</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>return "hello"</div>
<div class="">}</div>
<div class=""><br class="">
</div>
<div class="">let myValue = #run myFunction()</div>
<div class="">```</div>
<div class=""><br class="">
</div>
<div class="">At compile time, `myFunction` is evaluated and the result inlined to the `myValue` definition. At run time, `myValue` is a `String` containing `"hello"`.</div>
<div class=""><br class="">
</div>
<div class="">This is useful for tasks that are relatively expensive to run but only need to be done once, such as lookup tables. Running the algorithm to generate those tables can be handled at compile-time, and the results retrieved at no cost at run time. Furthermore,
 this structure allows code reuse between the run time and build time code, obviating the need to perform similar tasks in, say, a Swift method and a Python script.</div>
<div class=""><br class="">
</div>
<div class="">This is my first attempt at a Swift proposal, so any and all feedback is welcome! This seems like it should be easy enough to implement but I'm not especially familiar with Swift's internals. If there are any hurdles or unforeseen consequences associated
 with this from an implementation standpoint, that would be very useful to know.</div>
<div class=""><br class="">
</div>
<div class="">Thank you for your time!</div>
<div class=""><br class="">
</div>
<div class="">Best regards,</div>
<div class="">Steve Richey</div>
</div>

_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>