<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>Hi Jordan,</div><div><br></div><div>Sorry for the long delay in responding..</div><br><div><div>On Apr 23, 2013, at 3:17 PM, Jordan Rose <<a href="mailto:jordan_rose@apple.com">jordan_rose@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div><br class="Apple-interchange-newline">On Apr 23, 2013, at 13:46 , Argyrios Kyrtzidis <<a href="mailto:akyrtzi@gmail.com">akyrtzi@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div><div>On Apr 23, 2013, at 12:37 PM, Jordan Rose <<a href="mailto:jordan_rose@apple.com">jordan_rose@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Apr 23, 2013, at 12:16 , Argyrios Kyrtzidis <<a href="mailto:akyrtzi@gmail.com">akyrtzi@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">On Apr 23, 2013, at 12:03 PM, Jordan Rose <<a href="mailto:jordan_rose@apple.com">jordan_rose@apple.com</a>> wrote:<br><div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Sorry, why is this right way to implement this? 'self' is very deliberately not a special kind of expression in Objective-C. Why not expose this on the associated ParmVarDecl instead?<br></div></blockquote><div><br></div><div>What is the advantage with that approach ? Whether there is a ParmVarDecl or not seems like an implementation detail of the AST. If you are worried that there is one more cursor to consider, I'd argue the same applies for CXCursor_CXXThisExpr.</div></div></div></blockquote></div><br><div>CXXThisExpr matches the AST, which matches the C++ standard. There is no Objective-C standard, but certainly 'self' is not treated specially in most cases.</div></div></blockquote><div><br></div>Hmm, since 'self' is not declared anywhere in the source, I consider it somewhat "special".</div><div><br><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div><br></div><div>I can't put my finger on it, but it makes a lot more sense to me to say "is this variable 'self'?"</div></div></blockquote><div><br></div><div>What are you suggesting exactly, have "self" be a reference of a CXCursor_ParmDecl and introduce a libclang function to answer "is this parameter 'self'" ?</div><div><br></div><div><div>AFAIK you'd only get such a variable via a "'self' ref expression"; there is no other case where libclang is going to return such a thing, so such a function has limited utility.</div><div>And unless we start exposing "self" as a CXCursor_ParmDecl "child" of a method (which I don't like) it seems inconsistent that we would report as referenced a ParmDecl that we never reported before in the source.</div></div></div></div></blockquote><div><br></div><div><div>Hm. That's different from the Clang ASTs.</div></div></div></blockquote><div><br></div><div>For more context, 'self' decl is an ImplicitParamDecl, which is CXCursor_UnexposedDecl. You could only come upon this "unexposed decl" by calling clang_getCursorReferenced on the DeclRefExpr cursor.</div><br><blockquote type="cite"><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div><div>I guess you don't have a Decl for _cmd either?</div></div></div></blockquote><div><br></div><div>This is so rare that I'm fine with it working as I described above.</div><br><blockquote type="cite"><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div><div><br></div><div>But that makes sense—returning a Decl you won't see any other way doesn't feel consistent.</div><div><br></div><div>Now if you had something like liveness analysis, or "find all variables of this type", then it might be interesting to have 'self' as an explicit Decl. </div><div><br></div></div><br><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">than "is this expression 'self'?", especially in init methods where 'self' can be reassigned. 'this' can never be reassigned.</div></blockquote><div><br></div><div>Not sure why CXCursor_ObjCSelfExpr conflicts with 'self' getting reassigned ?</div></div></blockquote><br></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">It doesn't, but it seems funny to me to think of it as a special type of expression when it accepts assignment. Then again, so do ObjCPropertyRefExprs.</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Actually, it could be important for dependency analysis questions: "what variables might affect the value of this expression?". But now I'm talking about potential future APIs as justification for a decision now, which might not be worth it.</div></blockquote><div><br></div><div>I looked into it a bit more, and I'm afraid that it is a bit disruptive to start making 'self' a visible parameter of all methods. We may revisit this in the future but currently I'm uncomfortable making such a change.</div><br><blockquote type="cite"><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Jordan</div></blockquote></div><br></body></html>