<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><span></span></div><div><meta http-equiv="Content-Type" content="text/html charset=utf-8">I like to use the pipe operator for a functional programming style:<div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">infix</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);" class=""> </span><span style="font-variant-ligatures: no-common-ligatures;" class="">operator</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);" class=""> |> {</span><span style="font-variant-ligatures: no-common-ligatures;" class="">associativity</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);" class=""> left </span><span style="font-variant-ligatures: no-common-ligatures;" class="">precedence</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">100</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);" class="">}</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; min-height: 14px;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""></span><br class=""></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">public</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">func</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> |> <A, B> ( x: </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="">, f: </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">@noescape</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(187, 44, 162);" class="">throws</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="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">rethrows</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></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">return</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">try</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> f(x)</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">}</span></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; min-height: 14px;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""></span><br class=""></div></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; min-height: 14px;" class="">It lets me write x |> y |> z instead of z(y(x)) which I much prefer when x is a complicated expression.</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; min-height: 14px;" class="">The “rethrows” is great because it lets the “throwiness” of the functions shine through.</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; min-height: 14px;" class="">In my conversion to Swift 3, though, I am missing the same thing for @discardableResult.</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; min-height: 14px;" class="">I would like to use the same |> operator for functions with or without @discardableResults.</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; min-height: 14px;" class="">Is there a @rediscardableResult annotation? Or some other way to do this?</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; min-height: 14px;" class="">Thanks,</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; min-height: 14px;" class="">- David</div></div><div><br><br>- David (from iPad, typos likely)</div></body></html>