<div dir="ltr">Thanks to the magic of git blame:<div><br></div><div> <a href="https://github.com/apple/swift/commit/f3ed7e93e142b802171bfe0dd08b88aa0d8b320b">https://github.com/apple/swift/commit/f3ed7e93e142b802171bfe0dd08b88aa0d8b320b</a><br></div><div><br></div><div><br></div><div>> <span style="font-size:12.8px">Unless you think there’s something to be gained, I’m not sure it’s worth it…</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">I was going for idiot-proof-ness of the AST types. I'd never heard of CaptureListExpr before and would've just assumed it was part of ClosureExpr. But it looks like the change was pretty intentional. (Maybe someone can share what rdar://19146761 was?)</span></div><div class="gmail_extra"><div><div class="gmail_signature"><div dir="ltr"><div><br></div></div></div></div><div class="gmail_quote">On Tue, Feb 7, 2017 at 9:27 PM, John McCall <span dir="ltr"><<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><div><span class="gmail-"><blockquote type="cite"><div>On Feb 8, 2017, at 12:18 AM, Jacob Bandes-Storch via swift-dev <<a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a>> wrote:</div><div><div dir="ltr">I don't think it would be a very big parser change to invert the relationship. Maybe I'll try it out and put up another PR.</div></div></blockquote><blockquote type="cite"><div><div dir="ltr"><div><br></div><div>On the other hand, noticed the header comment says:</div><div><br></div><div><div>/// ...Because the capture list is evaluated outside of the closure, this</div><div>/// CaptureList wraps the ClosureExpr. The dynamic semantics are that evaluates</div><div>/// the variable bindings from the capture list, then evaluates the</div><div>/// subexpression (the closure itself) and returns the result.</div></div></div></div></blockquote><div><br></div></span>I think the original representation just made the captures part of the ClosureExpr, and IIRC Chris changed it to this intentionally. I don't remember why; maybe it was causing problems for some tooling that wanted to walk the expression tree and find uses of the variable? It's certainly kindof weird for IRGen.</div><span class="gmail-HOEnZb"><font color="#888888"><div><br></div><div>John.</div></font></span><span class="gmail-"><div><br></div><div><blockquote type="cite"><div><div dir="ltr"><div><div><br></div><div>🤷<br></div><div class="gmail_extra">
<br><div class="gmail_quote">On Tue, Feb 7, 2017 at 9:10 PM, Slava Pestov <span dir="ltr"><<a href="mailto:spestov@apple.com" target="_blank">spestov@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><br><div><span class="gmail-m_-7540441854893191245gmail-"><blockquote type="cite"><div>On Feb 7, 2017, at 9:09 PM, Jacob Bandes-Storch <<a href="mailto:jtbandes@gmail.com" target="_blank">jtbandes@gmail.com</a>> wrote:</div><br class="gmail-m_-7540441854893191245gmail-m_-7115685859560707654Apple-interchange-newline"><div><div dir="ltr">PR'd: <a href="https://github.com/apple/swift/pull/7326" target="_blank">https://github.com/apple/swif<wbr>t/pull/7326</a><div><br></div><div>Although I would also ask: why is CaptureListExpr a <b>parent</b> of ClosureExpr and not a child?</div></div></div></blockquote><div><br></div></span>I think it’s kind of arbitrary. You could also argue that they should be one and the same AST node. I think right now it’s just a property of how the parser works, the capture list comes first, before the closure body?</div><span class="gmail-m_-7540441854893191245gmail-HOEnZb"><font color="#888888"><div><br></div><div>Slava</div></font></span><span class="gmail-m_-7540441854893191245gmail-"><div><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><br clear="all"><div><div class="gmail-m_-7540441854893191245gmail-m_-7115685859560707654gmail_signature"><div dir="ltr"><div>Jacob<br></div></div></div></div>
<br><div class="gmail_quote">On Tue, Feb 7, 2017 at 7:56 PM, Slava Pestov <span dir="ltr"><<a href="mailto:spestov@apple.com" target="_blank">spestov@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><br><div><span><blockquote type="cite"><div>On Feb 7, 2017, at 7:30 PM, Jacob Bandes-Storch via swift-dev <<a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a>> wrote:</div><br class="gmail-m_-7540441854893191245gmail-m_-7115685859560707654m_-1882571583119174456Apple-interchange-newline"><div><div dir="ltr">I just learned about CaptureListExpr when working on some diagnostics. Is there a particular reason that its member "closureBody" is an Expr* and not a ClosureExpr*? There seems to be <a href="https://github.com/apple/swift/blob/1e46f13184d7256c991b2ba9424af9efe3cd860f/lib/Parse/ParseExpr.cpp#L2425" target="_blank">only one place it's built</a>, and the body is always a ClosureExpr.<div><br></div><div>I can see <a href="https://github.com/apple/swift/blob/1e46f13184d7256c991b2ba9424af9efe3cd860f/lib/AST/ASTWalker.cpp#L663-L665" target="_blank">one minor place</a> where it might be less convenient to have a ClosureExpr, but otherwise there doesn't seem to be much of a reason to keep it generalized to Expr*.</div></div></div></blockquote><div><br></div></span>Since autoclosures cannot have capture lists, I think the change you’re suggesting makes sense.</div><div><br></div><div>Slava</div><div><br><blockquote type="cite"><div><div dir="ltr"><div><div><br clear="all"><div><div class="gmail-m_-7540441854893191245gmail-m_-7115685859560707654m_-1882571583119174456gmail_signature"><div dir="ltr"><div>Jacob<br></div></div></div></div>
</div></div></div>
______________________________<wbr>_________________<br>swift-dev mailing list<br><a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-dev" target="_blank">https://lists.swift.org/mailma<wbr>n/listinfo/swift-dev</a><br></div></blockquote></div><br></div></blockquote></div><br></div></div>
</div></blockquote></div><br></span></div></blockquote></div><br></div></div></div>
______________________________<wbr>_________________<br>swift-dev mailing list<br><a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-dev" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-dev</a><br></div></blockquote></div><br></span></div></blockquote></div><br></div></div>