To me the short syntax should be a ‘macro’ expansion (syntax sugar only), therefore option 1 in Nick’s example. I choose the syntax sugar option because it is easy to explain.
-- Howard. > On 12 Dec 2017, at 7:03 pm, Nick Keets via swift-evolution > <swift-evolution@swift.org> wrote: > > > >> On Tue, Dec 12, 2017 at 12:42 AM, Slava Pestov via swift-evolution >> <swift-evolution@swift.org> wrote: >> >> I think it gets confusing when you have multiple levels of nested >> expressions, eg >> >> foo(bar(x?)) + y? >> >> Slava > > I'm not sure we need to optimize much for complicated nested examples, as I > don't think this is something that will happen a lot in practice. I imagine > the most common scenario will be a single call with one or more arguments. > > Having said that, we did receive 2 different reasonable answers on what the > evaluation order would be for: > f(a(), b?) > > (1) It desugars to: > > if let someB = b { > f(a(), someB) > } > > So a() doesn't get called if b is nil. > > (2) "If you were to write this logic out by hand then you would short-circuit > it and this is analogous to current chaining behaviour so to me evaluating > left to right (as Swift usually does) and stopping at the first failed unwrap > would make sense" > > So a() gets called if b is nil. > > > > _______________________________________________ > swift-evolution mailing list > swift-evolution@swift.org > https://lists.swift.org/mailman/listinfo/swift-evolution
_______________________________________________ swift-evolution mailing list swift-evolution@swift.org https://lists.swift.org/mailman/listinfo/swift-evolution