<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></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 Jan 9, 2016, at 4:29 AM, Dmitri Gribenko via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote">On Sat, Jan 9, 2016 at 10:53 AM, Andrew Bennett via swift-evolution <span dir="ltr" class=""><<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div class="">A function, method or closure is pure if:<br class=""></div><div class=""><div class=""> * all functions, methods and closures it calls are also pure (this includes referencing self from a method or property)</div><div class=""> * it only externally references let variables of pure type, let properties on those variables, and methods/computer-properties marked as pure.</div></div></div></blockquote><div class=""><br class=""></div><div class="">I'm concerned that with this definition we won't be able to mark many APIs as pure, even though they actually are pure. The issue is that this definition disallows local mutation. Consider CollectionType.sort() -- the way it is implemented is that it first copies the collection into an array, and then sorts that array in-place. sortInPlace() isn't pure, but because the mutation happens on local state, the whole operation is pure.</div></div></div></div></div></blockquote><div><br class=""></div><div>The way I ready it is "it only <b class="">externally</b> references let variables of pure type, let properties on those variables, and methods/computer-properties marked as pure.</div><div><br class=""></div><div>Externally is the key word here, which would allow for internal / local mutation. Note: properties of self would be an external reference.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><br class=""></div><div class="">Dmitri</div></div><div class=""><br class=""></div>-- <br class=""><div class="gmail_signature">main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if<br class="">(j){printf("%d\n",i);}}} /*Dmitri Gribenko <<a href="mailto:gribozavr@gmail.com" target="_blank" class="">gribozavr@gmail.com</a>>*/</div>
</div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=eLFMrKDT8iBxZ-2Fbnk-2BZqvSchNN-2FvYXdceA0T7VxwkAf856Z0Yxa-2FU-2Bq3BVtpE1uIXbmR4TQCaJejRptxxafkMGbsSfIMp4EClumzoWDRwYFbzfHsLe-2F17hlzf7-2FMO1WBuwJr0RoWke8XFw6ESGoLXPgrMRZ9qQFOsTdnotUZF1i-2Fta47Fs4va3xPkPr-2B0HjbZrj2HshqVeWXiEOm3gVZLKkWi46VRNrNDWA5LXDKeD0-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;" class="">
_______________________________________________<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>