<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 16, 2017, at 2:21 AM, Cao, Jiannan via swift-dev <<a href="mailto:swift-dev@swift.org" class="">swift-dev@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255);" class="">Hi all,</div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255);" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255);" class="">I have come up an improvement point about Optional Chain Assignment</div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255);" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255);" class="">1. Optional Chain Assignment not working with tuple assignment</div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255);" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255);" class="">optional chain assignment only work for directly assignment, not working with tuple assignment.</div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);" class=""><span style="font-family: Helvetica; font-size: 12px;" class=""><br class=""></span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);" class=""><span style="font-family: Helvetica; font-size: 12px;" class="">For example:</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);" class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255);" class=""><div style="color: rgb(186, 45, 162); font-family: Menlo; font-size: 11px; margin: 0px; font-stretch: normal; line-height: normal;" class=""><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><span style="color: #ba2da2" class="">struct</span> ListNode {</div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""> <span style="color: #ba2da2" class="">var</span> next: <span style="color: #4f8187" class="">ListNode</span>?</div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">}</div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: Helvetica; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><span style="color: #ba2da2" class="">var</span> previous: <span style="color: #4f8187" class="">ListNode</span>?</div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(79, 129, 135);" class=""><span style="color: #ba2da2" class="">var</span><span style="" class=""> current: </span>ListNode<span style="" class="">? = </span>ListNode<span style="" class="">()</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(79, 129, 135);" class=""><span style="" class=""><br class=""></span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(79, 129, 135);" class=""><span style="" class="">//original version</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(79, 129, 135);" class=""><span style="" class="">let temp = </span>current?.next</div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(79, 129, 135);" class="">current<span style="" class="">?.next = </span>previous</div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(79, 129, 135);" class="">previous = current</div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(79, 129, 135);" class="">current = temp</div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: Helvetica; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: Helvetica; min-height: 14px;" class=""><div style="margin: 0px; font-stretch: normal; line-height: normal; min-height: 14px;" class=""><div style="margin: 0px; font-stretch: normal; line-height: normal; min-height: 14px;" class="">// tuple assignment version (currently compiler error)</div></div></div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(79, 129, 135);" class=""><span style="" class="">(</span>current<span style="" class="">?.next, </span>previous<span style="" class="">, </span>current<span style="" class="">) = (</span>previous<span style="" class="">, </span>current<span style="" class="">, </span>current<span style="" class="">?.next)</span></div><div class=""><br class=""></div></div></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><b class="">error: cannot assign to immutable expression of type '_?'</b></div></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><b class="">(current?.next, previous, current) = (previous, current, current?.next)</b></span></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><b class=""> ~~~~~~~~~~~~~ ^</b></span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><b class=""><br class=""></b></span></div></div></div></div></blockquote><div class="">Should we improve this situation?</div></div></div></blockquote><div><br class=""></div>Optional chain assignment normally prevents the RHS of the assignment from being evaluated if the chain is aborted. What do you recommend as the semantics here? What if the optional element is later in the sequence?</div><div><br class=""></div><div>John.</div></body></html>