<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 12 January 2014 04:52, Adam D. Ruppe <span dir="ltr"><<a href="mailto:destructionator@gmail.com" target="_blank">destructionator@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Saturday, 11 January 2014 at 18:48:15 UTC, Maxim Fomin wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
It is legal exactly because function is marked as pure. Result of pure function is implicitly convertible to immutable.<br>
</blockquote>
<br></div>
It shouldn't be here though... the reason it is implicitly convertable is that pure means the result is unique.</blockquote><div><br></div><div>Can you explain how this is true? I can't see anything about the concept of purity that suggests the result should be unique...</div>
<div>Pure just means given the same inputs, it will produce the same outputs; external state can't affect the calculation.</div><div><br></div><div>In this case, that's perfectly true. 'this' is just a function arg; it's not mutated by external state (or at all), given the same this, it will return the same thing every time.</div>
<div>That doesn't make any claims about what 'this' is though, and whether it's immutable or 'unique' or whatever. It just promises to transform it in an identical way given the same inputs...</div>
<div>?</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> But, with the hidden this pointer having a reference to the data as well, it obviously is not unique. I think the compiler should catch this; i'd call it a bug.<br>

</blockquote></div><br></div></div>