<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 27, 2014 at 9:19 AM, Levente Uzonyi <span dir="ltr">&lt;<a href="mailto:leves@elte.hu" target="_blank">leves@elte.hu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Mon, 27 Oct 2014, Clément Bera wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hey guys,<br>
I was discussing about methods like that with Marcus:<br>
<br>
MyClass&gt;&gt;foo<br>
#(false) first <br>
ifFalse: [ <br>
&#39;first call since compilation&#39; logCr. <br>
#(false) at: 1 put: true ]<br>
ifTrue: [ &#39;other calls&#39; logCr ]<br>
<br>
DoIt:<br>
4 timesRepeat: [MyClass new foo ]<br>
<br>
Transcript:<br>
&#39;first call since compilation&#39;<br>
&#39;other calls&#39;<br>
&#39;other calls&#39;<br>
&#39;other calls&#39;<br>
<br>
In the sista image/VM, we are most probably going with Eliot to implement a slow path when you edit the literal of a method (deoptimizing the method) so we can consider that the literals are immutable in the<br>
generic case (and if it&#39;s not true, execution falls back to a slow path).<br>
<br>
But I was thinking, does it worth it to implement the slow path ? <br>
Couldn&#39;t we just put literals as immutable all the time ? <br>
The methods as the one shown before would not work any more. But does someone use it ?<br>
</blockquote>
<br></div></div>
This method was used in Seaside (or some Seaside extension) to cache the contents of files in methods.<br>
<br>
By the way, how would you ensure immutability?<br></blockquote><div><br></div><div>See my message earlier in the thread.  Via a per-object isImmutable bit.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I mean, how would you prevent something like this?<br>
<br>
MyClass &gt;&gt; foo<br>
<br>
        ^#(&#39;placeHolder&#39;)<br>
<br>
And then<br>
<br>
(((MyClass &gt;&gt; #foo) literalAt: 1) at: 1) becomeForward: Object new<br>
<br>
<br>
Levente<br>
<br>
P.S.: why isn&#39;t this on the vm-dev list?<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
...<br>
<br>
<br>
</blockquote>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div>
</div></div>