<head></head><body>Slight tangent, would a guarantee of purity also allow for more Tail-Call Optimizations? A cursory glance at SO seems to point to TCO not always being applied, especially when ARC is involved.<div><div><br></div><br<br>—<div>Alex Popov Jr.</div><div>Principal iOS Developer | Shelfie</div></br<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
On Dec 21 2015, at 1:55 pm, Joe Groff via swift-evolution <swift-evolution@swift.org> wrote:
<br>
<meta content="text/html charset=utf-8"><br><div><blockquote type="cite"><div>On Dec 21, 2015, at 1:49 PM, Chris Lattner via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:</div><br><div><meta content="text/html charset=utf-8"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><blockquote type="cite"><div>On Dec 21, 2015, at 12:05 PM, Jacob Bandes-Storch <<a href="mailto:jtbandes@gmail.com">jtbandes@gmail.com</a>> wrote:</div><br><div><div dir="ltr"><div><div>On Mon, Dec 21, 2015 at 11:55 AM, Chris Lattner via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div>…there probably has to be some way to unsafely “force a call to a non-pure function to be allowed in a pure one”, both because of type system limitations as well as interoperability with C and other languages. Even ignoring issues around errno, it would be sad for a pure function to not be able to call “sin(x)” just because it weren’t marked __attribute__((const)).</div></div></div></blockquote><div><br></div><div>Minor tangent, but should the same apply to @noescape? </div></div></div></div></div></blockquote><br></div><div>Yes, it should. I believe you can currently use an unsafe cast to remove @noescape, and that the stdlib does it in a few places. Dmitri, do you know where?</div></div></div></blockquote><br></div><div>The runtime does this using unsafeBitCast, but don't follow its example—I don't want to promise this will always be possible. There are representation optimizations we can do with @noescape closures that would be blocked if they always had to be bitcastable to refcounted escapable closures. I'd like to introduce a `Builtin.makeEscapable` operation specifically to go from @noescape to escapable, introducing a refcounting shim if necessary in the future.</div><div><br></div><div>-Joe</div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=CmwAv3oRa0AH4Hd1bWC6X-2BzbhPqo1YEo6mPHEujr90vNqvSlNKW0iy2BTd4OxR0SCJAwyLx2cZ3twpk4M4WqgQG-2FHUcfU2eLopRmdzTmpLuLZtOY1eD9WFERKSEU-2Fh8ZpSXZO8n-2FxFdugKSpD2tVIHo-2B1Xm1Kx9Z6REnSigwhXQc1ZZ21GoUrVYCyW9mvlG9yTXA-2F8-2BkRL3jMogyILA8zEwqIWg15KQWC24Bm6WqsLc-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;">
</blockquote></body>