<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2014-10-28 0:19 GMT+01:00 Levente Uzonyi <span dir="ltr">&lt;<a href="mailto:leves@elte.hu" target="_blank">leves@elte.hu</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
On Mon, 27 Oct 2014, stepharo wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Levente<br>
<br>
I think that the first step is not to make sure that you cannot hack inside literals like mad. But to make sure that in 99.99 % of the case, this assumption can hold.<br>
<br>
Stef<br>
</blockquote>
<br>
Let me sum it up:<br>
- The question is (by Clement) if it&#39;s okay to not implement the slow path.<br>
- He assumes that he doesn&#39;t have to implement it if literals are immutable.<br>
- I showed that literal immutability is not enough to avoid impelemting the slow path.<br>
<br>
So immutability doesn&#39;t affect anything about the need for implementing of the slow path. If Clement decides to not implement it, then one will be able to get the system into an inconsistent state, no matter if literals are immutable or not.<br>
<br>
If you think that the inconsistent state can only be achieved by hacking, then here&#39;s another example without &quot;hacks&quot;:<br>
<br>
SomeClass &gt;&gt; #someMethod<br>
<br>
        ^someBoolean<br>
                ifTrue: [ Array with: 1 with: 2 with: 3 ]<br>
                ifFalse: [ Array empty &quot;we don&#39;t have to create a new array for this, right? :)&quot; ]<br>
<br>
SomeOtherClass &gt;&gt; #someOtherMethod: anArray<br>
<br>
        | copy |<br>
        anArray doSomething.<br>
        &quot;let&#39;s grow that array&quot;<br>
        copy := Array new: anArray size.<br>
        copy replaceFrom: 1 to: anArray size with: anArray startingAt: 1.<br>
        anArray becomeForward: copy. &quot;this is really cheap in Spur (and in VW; even collections and streams use it)&quot;<br>
<br>
ThirdClass &gt;&gt; #yetAnotherMethod: aSomeClass<br>
<br>
        | x |<br>
        x := aSomeClass someMethod.<br>
        y someOtherMethod: x.<br>
        ^x<br>
<br>
And now, when #yetAnotherMethod: is sent, we swap the literal in Array class &gt;&gt; #empty with another non-empty array. Based on Eliot&#39;s comment about VW, I&#39;m pretty sure the VW guys had problems like this, despite of having immutable literals.<span class="HOEnZb"><font color="#888888"><br>
<br>
Levente<br>
</font></span></blockquote></div><br></div><div class="gmail_extra">But is there a becomeForward: in VW?<br></div></div>