[swift-users] is there a @rediscardableResult like rethrows?

David Ungar ungar at mac.com
Wed Jun 22 14:06:44 CDT 2016


I like to use the pipe operator for a functional programming style:

infix operator |> {associativity left precedence 100}

public func |>  <A, B> ( x: A, f: @noescape (A) throws -> B ) rethrows  -> B {
    return try f(x)
}


It lets me write x |> y |> z instead of z(y(x)) which I much prefer when x is a complicated expression.

The “rethrows” is great because it lets the “throwiness” of the functions shine through.

In my conversion to Swift 3, though, I am missing the same thing for @discardableResult.
I would like to use the same |> operator for functions with or without @discardableResults.
Is there a @rediscardableResult annotation? Or some other way to do this?

Thanks,

- David


- David (from iPad, typos likely)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160622/8d28d331/attachment.html>


More information about the swift-users mailing list