<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="">I would think it would be functionally equivalent to Scala.<div class=""><br class=""></div><div class="">for {</div><div class="">&nbsp; &nbsp;o1 &lt;- optional1</div><div class="">&nbsp; &nbsp;o2 &lt;- optional2</div><div class="">&nbsp; &nbsp;..</div><div class="">} yield { manager.doSumething(data, o1, o2) }</div><div class=""><br class=""></div><div class="">which is a combination of maps and flatMaps.</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 2016-01-30, at 1:06:00, Jacob Bandes-Storch &lt;<a href="mailto:jtbandes@gmail.com" class="">jtbandes@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class="">Another conundrum: are the optional-pattern arguments evaluated before any other arguments? After?<br class=""><div class="gmail_quote"><div dir="ltr" class="">On Fri, Jan 29, 2016 at 9:54 AM Paul Ossenbruggen &lt;<a href="mailto:possen@gmail.com" class="">possen@gmail.com</a>&gt; wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto" class=""><div class="">Yeah I was thinking about that too, multiple optionals. It gets a bit confusing as to the scope. &nbsp;</div><div class=""><br class=""></div><div class="">Wondering if we should pass it on as an optional or not allow it? Something else?<br class=""><br class="">Sent from my iPhone</div></div><div dir="auto" class=""><div class=""><br class="">On Jan 29, 2016, at 9:26 AM, Jacob Bandes-Storch &lt;<a href="mailto:jtbandes@gmail.com" target="_blank" class="">jtbandes@gmail.com</a>&gt; wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class="">Hi Paul,<br class="">I think the two statements would behave separately (as if you had used map twice).<br class=""><br class="">If you want them to act together, you could do this: <br class=""><br class="">    { manager.doSomething(data: data, count: $0); doSomethingElse($0) }(n?)<br class=""><br class="">Another aspect worth considering is whether this syntax should work with multiple optionals used in the same expression. (e.g. if they are all non-nil, the expression is evaluated.)<br class=""><div class="gmail_quote"><div dir="ltr" class="">On Fri, Jan 29, 2016 at 1:53 AM Paul Ossenbruggen &lt;<a href="mailto:possen@gmail.com" target="_blank" class="">possen@gmail.com</a>&gt; wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">Jacob,</div><div class=""><br class=""></div>While working on proposal, I am just trying to understand one thing with this. In your second example using map, it is clear where the block of code begins. How would you deal with multiple statements or ones that returned no value:<div class=""><br class=""></div><div class=""><div class="gmail_quote"><div style="word-wrap:break-word" class=""><div class=""><div class=""><div class=""><div dir="ltr" class=""><div class="">&nbsp; &nbsp; <span style="white-space:pre-wrap" class="">        </span>manager.doSomething(data: data, count: n?); doSomethingElse( n?)</div><div class=""><br class=""></div><div class="">the equivalent with map is</div><div class=""><br class=""></div><div class=""><div class="gmail_quote"><div style="word-wrap:break-word" class=""><div class=""><div class=""><div class=""><div dir="ltr" class=""><div class=""><span style="white-space:pre-wrap" class="">        </span>n.map { manager.doSomething(data: data, count: $0); doSomethingElse($0) &nbsp;}</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">- Paul</div><div class=""><br class=""></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div><div style="word-wrap:break-word" class=""><div class=""><div class=""><div class=""><blockquote type="cite" class=""><div class="">On Jan 28, 2016, at 8:41 PM, Jacob Bandes-Storch &lt;<a href="mailto:jtbandes@gmail.com" target="_blank" class="">jtbandes@gmail.com</a>&gt; wrote:</div><br class=""><div class="">That'd be the point. If doSomething were not optional, when "n?" appears in it, it becomes optional (it's basically optional chaining, but for function calls and other expressions instead of just dot-notation).<br class=""><div class="gmail_quote"><div dir="ltr" class="">On Thu, Jan 28, 2016 at 8:38 PM Craig Cruden &lt;<a href="mailto:ccruden@novafore.com" target="_blank" class="">ccruden@novafore.com</a>&gt; wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><br class=""></div><blockquote type="cite" class=""><div dir="ltr" class=""><div class="">&nbsp; &nbsp; manager.doSomething(data: data, count: n?)</div></div></blockquote><div class=""><br class=""></div>What if the return value of doSomething is not an optional?&nbsp; Expressions are easy — but there might be some conflicts with this one.</div><div style="word-wrap:break-word" class=""><div class=""><br class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div></div></div><div class=""><blockquote type="cite" class=""><div class="">On 2016-01-28, at 14:34:58, Jacob Bandes-Storch via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class=""><div class=""><div dir="ltr" class="">I've wanted this sort of thing a lot. It would also work for other functions, such as<div class=""><br class=""></div><div class="">&nbsp; &nbsp; manager.doSomething(data: data, count: n?)</div><div class=""><br class=""></div><div class="">which is equivalent to</div><div class=""><br class=""></div><div class="">&nbsp; &nbsp; n.map { manager.doSomething(data: data, count: $0) }</div><div class="gmail_extra"><br class=""></div><div class="gmail_extra">It might be hard to see exactly which operator/function applications such a thing applies to, if used in the context of a complex expression.</div><div class="gmail_extra"><br clear="all" class=""><div class=""><div class=""><div dir="ltr" class=""><div class="">Jacob<br class=""></div></div></div></div>
<br class=""><div class="gmail_quote">On Wed, Jan 27, 2016 at 9:50 PM, Paul Ossenbruggen via swift-evolution <span dir="ltr" class="">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">Maybe something like this?<div class=""><br class=""></div><div class=""><span class=""><div class=""><div style="margin:0px;line-height:normal;font-family:Menlo" class=""><span style="color:#bb2ca2" class="">let</span> n : <span style="color:#703daa" class="">Int</span>? = <span style="color:#272ad8" class="">5</span></div><div class=""><span style="color:#272ad8" class=""><br class=""></span></div></div></span><div class=""><div style="margin:0px;line-height:normal;font-family:Menlo" class=""><span style="color:#bb2ca2" class="">let</span> r = <span style="color:#4f8187" class="">n</span>? + <span style="color:#272ad8" class="">5</span></div><div class=""><span style="color:#272ad8" class=""><br class=""></span></div><div class=""><span style="color:#272ad8" class=""><br class=""></span></div></div><div class=""><div class=""><div class=""><blockquote type="cite" class=""><div class="">On Jan 27, 2016, at 9:46 PM, Thorsten Seitz &lt;<a href="mailto:tseitz42@icloud.com" target="_blank" class="">tseitz42@icloud.com</a>&gt; wrote:</div><br class=""><div class=""><div dir="auto" class=""><div class=""></div><div class="">Too much hidden magic IMO. This would mean loosing the benefits of optionals, i.e. making explicit where optional cases occur and that handling the missing case has to be considered.&nbsp;</div><div class=""><br class=""></div><div class="">-Thorsten&nbsp;</div><div class=""><br class="">Am 28.01.2016 um 06:30 schrieb Craig Cruden via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;:<br class=""><br class=""></div><blockquote type="cite" class=""><div class="">Yes<br class=""><div class=""><blockquote type="cite" class=""><div class="">On 2016-01-28, at 12:28:40, Paul Ossenbruggen &lt;<a href="mailto:possen@gmail.com" target="_blank" class="">possen@gmail.com</a>&gt; wrote:</div><br class=""><div class=""><div style="word-wrap:break-word" class="">Trying to see if I got this. So the type of r would be Int? at the end of this? And if n were nil then r would be nil? Otherwise it r is 10?<div class=""><br class=""></div><div class=""><div class=""><br class=""></div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jan 27, 2016, at 9:19 PM, Craig Cruden via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class=""><div class=""><div style="word-wrap:break-word" class="">Swift currently encourages a lot of conditional code - especially when it comes to optionals.&nbsp; In most cases when you are computing etc. on an Optional you would expect that you would want an optional result and things to be able to use optionals. &nbsp;<div class=""><br class=""></div><div class="">In another language I generally just `map` one optional to another - which may not be the most readable code to some not use to optionals. &nbsp;</div><div class=""><br class=""></div><div class="">I was wondering if maybe an expression is not available that it would rewrite the syntax to map from one to another value. &nbsp;</div><div class=""><br class=""></div><div class="">So things like:</div><div class=""><br class=""></div><div class="">let n : Int? = 5</div><div class=""><br class=""></div><div class="">let r = n + 5</div><div class=""><br class=""></div><div class="">would actually compile as&nbsp;</div><div class=""><br class=""></div><div class="">let r = n.map&nbsp;<span style="font-family:Menlo;font-size:11px" class="">{$0 + </span><span style="font-family:Menlo;font-size:11px;color:rgb(39,42,216)" class="">5</span><span style="font-family:Menlo;font-size:11px" class="">}</span></div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div></div></div></div></blockquote></div><br class=""></div></blockquote><blockquote type="cite" class=""><div class=""><span class="">_______________________________________________</span><br class=""><span class="">swift-evolution mailing list</span><br class=""><span class=""><a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br class=""></div></blockquote></div></div></blockquote></div><br class=""></div></div></div></div><br class="">_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
<br class=""></blockquote></div><br class=""></div></div>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div></div></blockquote></div>
</div></blockquote></div><br class=""></div></div></div></blockquote></div>
</div></blockquote></div></blockquote></div>
</div></blockquote></div><br class=""></div></body></html>