<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<br><div><div>On Aug 17, 2007, at 10:10 AM, Steve Naroff wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><div>I have no problem with the extra checking. I do have another suggestion:</div><div><br class="khtml-block-placeholder"></div><div>Why not simply change the following...</div><div><br class="khtml-block-placeholder"></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" face="Monaco" size="2"><span class="Apple-style-span" style="font-size: 10px; ">  </span></font><font class="Apple-style-span" color="#760F50" face="Monaco" size="2"><span class="Apple-style-span" style="font-size: 10px; ">return</span></font><font class="Apple-style-span" face="Monaco" size="2"><span class="Apple-style-span" style="font-size: 10px; "><span class="Apple-converted-space"> </span></span></font><font class="Apple-style-span" color="#760F50" face="Monaco" size="2"><span class="Apple-style-span" style="font-size: 10px; ">new</span></font><font class="Apple-style-span" face="Monaco" size="2"><span class="Apple-style-span" style="font-size: 10px; "><span class="Apple-converted-space"> </span>ArraySubscriptExpr(LHSExp, RHSExp, ResultType, RLoc);</span></font></div><div><br class="khtml-block-placeholder"></div><div>to...</div><div><br class="khtml-block-placeholder"></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" face="Monaco" size="2"><span class="Apple-style-span" style="font-size: 10px; ">  </span></font><font class="Apple-style-span" color="#760F50" face="Monaco" size="2"><span class="Apple-style-span" style="font-size: 10px; ">return</span></font><font class="Apple-style-span" face="Monaco" size="2"><span class="Apple-style-span" style="font-size: 10px; "><span class="Apple-converted-space"> </span></span></font><font class="Apple-style-span" color="#760F50" face="Monaco" size="2"><span class="Apple-style-span" style="font-size: 10px; ">new</span></font><font class="Apple-style-span" face="Monaco" size="2"><span class="Apple-style-span" style="font-size: 10px; "><span class="Apple-converted-space"> </span>ArraySubscriptExpr(BaseExpr, IndexExpr, ResultType, RLoc);</span></font></div><div><br class="khtml-block-placeholder"></div><div>? And keep everything else the same...</div><div><br class="khtml-block-placeholder"></div><div>The only disadvantage with this is the crazy case of idx[base] will always be output as base[idx] (if we are doing a pretty printer or source analysis tool). From my perspective, this loss is extremely minor (and can be fixed one day if necessary). In other words, I think it makes sense for the AST to normalize this case.</div></span></blockquote></div><br><div>Steve and I just discussed this in person.</div><div><br class="webkit-block-placeholder"></div><div>We decided that we will have BaseExpr and IndexExpr refer to the true "base" and "index" respectively (just as in Steve's post), but then add getLHS() and getRHS() methods to ArraySubscriptExpr that return the lexically "left" and "right" expressions based on comparing their SourceLocations.</div><div><br class="webkit-block-placeholder"></div><div>This will allow the common case that does semantic analysis on the AST to not have any extra logic when doing getBase() and getIdx().  For tools requiring manipulating expressions at the source level, we have getLHS() and getRHS().  This will be the slightly slower than getBase()/getIdx() (but likely unnoticeable in performance for such applications).</div></body></html>