<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; "><div><div>On Dec 7, 2012, at 12:01 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"><span style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; display: inline !important; float: none; ">This broke the build for me; it's not const-correct. Moreover, it's<span class="Apple-converted-space"> </span></span><i style="font-family: Helvetica; font-size: medium; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; ">really</i><span style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; display: inline !important; float: none; "> not const-correct. A const ImmutableMapRef is the same as a const ImmutableMap::Factory: it means you're not going to try to generate new maps from it.</span></blockquote><br></div><div>It's const because the data structure itself does not change.  That seems worth capturing with 'const'.  The underlying factory object mutates, but that seems reasonable to me.</div><div><br></div><div>Suppose I had written...</div><div><br></div><div>   ImmutableMapRef remove(key_type_ref K) const {</div><div>     TreeTy *NewT = Factory->remove(Root, K);</div><div>     return ImmutableMapRef(NewT, Factory);</div><div>   }</div><div><br></div><div>as:</div><div><br></div><div><div>  ImmutableMapRef remove(key_type_ref K, FactoryTy *Factory) const {</div><div>     TreeTy *NewT = Factory->remove(Root, K);</div><div>     return ImmutableMapRef(NewT, Factory);</div><div>   }</div><div><br></div><div>That is essentially functionally the same thing.  The factory is really an implementation detail.  'const' does not mean that a method does not mutate state anywhere.  In this case, I'm saying that the data itself does not mutate, which is true.  This allows important optimizations.  For example, it allows us to bind a const & to an ImmutableMapRef and still use add and remove.</div></div></body></html>