I do not feel new syntax is needed for this.
You can do this currently:

postfix operator ¿

extension Optional {
    struct UnwrapError: Error {}
    static postfix func ¿(_ value: Optional) throws -> Wrapped {
        if let value = value {
            return value
        } else {
            throw UnwrapError()

Given function f: (Foo, Foo, Foo) -> Void
and functions a, b, c: () -> Foo?
you would then chain the calls like

try? f(a()¿, b()¿, c()¿)

This is hardly more verbose than

f(a()?, b()?, c()?)

At least on mac keyboard ¿ is not hard to type either.
Also everyone is free to bikeshed the operator to their liking.

If special syntax were to be added for this, then in my opinion
the behaviour should mimic this; i.e. evaluate arguments left-to-right,
abort on first nil.

swift-evolution mailing list

Reply via email to