<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Sep 1, 2016, at 12:37 PM, Lou Zell via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span style="font-size:12.8px" class="">As to your real question, what’s your high-level goal?&nbsp; Swift doesn’t really do pointers to functions [1] but it does provide lots of other excellent ‘treat code as data’ features.&nbsp; If you can explain more about your goal, perhaps we can direct you to a better path.</span><br class=""></blockquote>​<div class="">Curiosity got the better of me on this one - there's no higher level goal other than improved understanding.&nbsp; I was playing around with function currying in the repl and that's what lead me to those experiments. &nbsp;</div><div class=""><br class=""></div><div class="">The article, and the preceding one in the series, has plenty for me to work with.&nbsp; Thank you!</div></div></div></blockquote><br class=""></div><div>That’s an awesome article, but I don’t think you need to understand any of it! I’m not an expert in this either, but here’s what I can see from your code...</div><div><br class=""></div><div>It looks like you’re trying to capture the address of a function that was JIT’d for the purpose of evaluating a statement in the repl. That address might not be valid in the next statement.</div><div><br class=""></div><div>Also, in the first case the UnsafePointer points to local memory that holds the function value. In the second case, you’re trying to load a function value from the address of the function body. So a level of indirection is missing.</div><div><br class=""></div><div>You can’t take an address to a function in Swift. You can assign a variable to the function, as you did in the first case:</div><div><br class=""></div><div>var x = doNothing</div><div><br class=""></div><div>And view the address of that variable as an argument, only for the duration of the call, as you did in the first case:</div><div><br class=""></div><div>call(&amp;x)</div><div><br class=""></div><div>-Andy</div><br class=""></body></html>