<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=""><div class=""><blockquote type="cite" class=""><div class=""><div name="messageBodySection" class="">But given the scope capturing nature of closures I was actually wondering if this 'purity' should be applied to closures.<br class=""></div></div></blockquote></div>I think It should, pure closure cannot have outside references and therefore cannot create reference cycles even though they are escaping.<div class=""><br class=""><div class="">I tend toward using the => sign since it doesn't require a lot of change, it has a nice lightweight syntax and seems different enough from -> .</div><div class="">The pure keyword in front of the function signature looks like a lot of noise for such a simple concept. And It will only get worse in function signatures.</div><div class=""><br class=""></div><div class="">see the difference between </div><div class=""><br class=""></div><div class=""><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">func</span><span style="font-variant-ligatures: no-common-ligatures" class=""> pureCurryCompose<A, B, C>(f: </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">@pure</span><span style="font-variant-ligatures: no-common-ligatures" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">B</span><span style="font-variant-ligatures: no-common-ligatures" class="">) -> </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">C</span><span style="font-variant-ligatures: no-common-ligatures" class="">) -> </span><span style="color: rgb(186, 45, 162);" class="">@pure</span><span style="font-variant-ligatures: no-common-ligatures;" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);" class="">@pure</span><span style="font-variant-ligatures: no-common-ligatures;" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);" class="">A</span><span style="font-variant-ligatures: no-common-ligatures;" class="">) -> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);" class="">B</span><span style="font-variant-ligatures: no-common-ligatures;" class="">) -> (</span><span style="color: rgb(186, 45, 162);" class="">@pure</span><span style="font-variant-ligatures: no-common-ligatures;" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);" class="">A</span><span style="font-variant-ligatures: no-common-ligatures;" class="">) -> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);" class="">C)</span></div></div><div class=""><br class=""></div><div class="">and </div><div class=""><br class=""></div><div class=""><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">func</span><span style="font-variant-ligatures: no-common-ligatures" class=""> pureCurryCompose<A, B, C>(f: (</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">B</span><span style="font-variant-ligatures: no-common-ligatures" class="">) => C) => ((A) => B) => (A) => C</span></div></div><div class=""><br class=""></div><div class="">The second is easiest to read.</div><div class=""><br class=""></div><div class="">(of course I would argue that </div><div class=""><span style="font-family: Menlo; font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);" class=""><br class=""></span></div><div class=""><span style="font-family: Menlo; font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);" class="">func</span><span style="font-family: Menlo; font-variant-ligatures: no-common-ligatures;" class=""> pureCurryCompose<A, B, C>(f: </span><span style="font-family: Menlo; font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);" class="">B</span><span style="font-family: Menlo; font-variant-ligatures: no-common-ligatures;" class=""> => C) => (A => B) => (A => C</span>) </div><div class=""><br class=""></div><div class="">is the most readable of all but I'm too late for that proposal )</div><div class=""><br class=""></div><div class=""><div><blockquote type="cite" class=""><div class="">On 17 Feb 2017, at 18:02, Florent Vilmart 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="">
<title class=""></title>
<div class="">
<div name="messageBodySection" class="">We could do:<br class="">
<br class="">
pure let closure = { _-> Else in }<br class="">
<br class="">
But given the scope capturing nature of closures I was actually wondering if this 'purity' should be applied to closures.<br class="">
<br class="">
After all an inline defined func would do.</div>
<div name="messageSignatureSection" class=""><br class=""></div>
<div name="messageReplySection" class=""><br class="">
On Feb 17, 2017, 11:59 AM -0500, Matthew Johnson <<a href="mailto:matthew@anandabits.com" class="">matthew@anandabits.com</a>>, wrote:<br class="">
<blockquote type="cite" class="">How do you suggest a closure indicate its purity? Something like this?
<div class=""><br class=""></div>
<div class="">{ pure in $0.property }
<div class=""><br class="">
<div class="">
<blockquote type="cite" class="">
<div class="">On Feb 17, 2017, at 10:57 AM, Florent Vilmart <<a href="mailto:florent@flovilmart.com" class="">florent@flovilmart.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="">
<div name="messageBodySection" class="">We were discussing the topic yesterday with others and some suggested adding a pure keyword, for improved readability, just before the function declaration:<br class="">
<br class="">
Ex:<br class="">
<br class="">
pure func(a:Some) -> Else {}<br class="">
<br class=""></div>
<div name="messageSignatureSection" class=""><br class=""></div>
<div name="messageReplySection" class=""><br class="">
On Feb 17, 2017, 11:51 AM -0500, Matthew Johnson via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>>, wrote:<br class="">
<blockquote type="cite" class=""><br class="">
<div class="">
<blockquote type="cite" class="">
<div class="">On Feb 17, 2017, at 10:46 AM, David Sweeris 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 style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(254, 254, 254);" class=""><br class="Apple-interchange-newline">
On Feb 17, 2017, at 08:21, Adrian Zubarev via swift-evolution <<a href="mailto:swift-evolution@swift.org" style="color: rgb(65, 131, 196); background-color: inherit; text-decoration: none;" class="">swift-evolution@swift.org</a>> wrote:<br class="">
<br class=""></div>
<blockquote type="cite" style="margin: 15px 0px; font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(254, 254, 254);" class="">
<div style="margin-top: 0px; margin-bottom: 0px;" class="">
<div class="bloop_markdown"><p style="margin: 15px 0px; -webkit-margin-before: 0px;" class="">I haven’t yet read all the feedback in this topic but I’d like to throw some bikeshedding of mine into the room. :)</p><p style="margin: 15px 0px;" class="">How about this?</p>
<ul style="margin: 15px 0px;" class="">
<li style="margin: 15px 0px; -webkit-margin-before: 0px;" class="">Version 1:<span class="Apple-converted-space"> </span><code style="font-family: Menlo, Consolas, 'Liberation Mono', Courier, monospace; font-size: 10pt; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(248, 248, 248); color: inherit; border: 1px solid rgb(234, 234, 234); margin: 0px 2px; padding: 0px 5px; word-break: normal; word-wrap: normal; -webkit-margin-before: 0px;" class="">func(pure) …</code></li>
<li style="margin: 15px 0px;" class="">Version 2:<span class="Apple-converted-space"> </span><code style="font-family: Menlo, Consolas, 'Liberation Mono', Courier, monospace; font-size: 10pt; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(248, 248, 248); color: inherit; border: 1px solid rgb(234, 234, 234); margin: 0px 2px; padding: 0px 5px; word-break: normal; word-wrap: normal; -webkit-margin-before: 0px;" class="">func label(…) ~> ReturnType</code></li>
</ul>
</div>
</div>
</blockquote>
<span style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(254, 254, 254); float: none; display: inline !important;" class="">Version 2 is going to upset those who use "~>" as an operator.</span>
<div style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(254, 254, 254);" class=""><br class=""></div>
<div style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(254, 254, 254);" class="">As the # of possible attributes grows, having an obvious grouping mechanism for them, like version 1, might be worthwhile simply to help make the list clearer. What about allowing "@(list, of, attributes)" instead of "<span style="background-color: rgba(255, 255, 255, 0);" class="">@list, @of, @attributes”?</span></div>
</div>
</blockquote>
<div class=""><br class=""></div>
<div class="">That would be a little bit awkward for attributes that are parameterized. And if we did do this we should allow the parens to be omitted when there is only one attribute.</div>
<br class="">
<blockquote type="cite" class="">
<div class="">
<div style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(254, 254, 254);" class=""><span style="background-color: rgba(255, 255, 255, 0);" class=""><br class=""></span></div>
<div style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(254, 254, 254);" class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">- Dave Sweeris</span></div>
<span style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(254, 254, 254); float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(254, 254, 254);" class="">
<span style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(254, 254, 254); float: none; display: inline !important;" class="">swift-evolution mailing list</span><br style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(254, 254, 254);" class="">
<a href="mailto:swift-evolution@swift.org" style="color: rgb(65, 131, 196); background-color: rgb(254, 254, 254); text-decoration: none; font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">swift-evolution@swift.org</a><br style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(254, 254, 254);" class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="color: rgb(65, 131, 196); background-color: rgb(254, 254, 254); text-decoration: none; font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(254, 254, 254);" class=""></div>
</blockquote>
</div>
<br class="">
_______________________________________________<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=""></blockquote>
</div>
</div>
</div>
</blockquote>
</div>
<br class=""></div>
</div>
</blockquote>
</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="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></div></body></html>