<br><br><div class="gmail_quote">On Wed, Oct 13, 2010 at 9:22 AM, Igor Stasenko <span dir="ltr">&lt;<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</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="im">On 13 October 2010 18:54, Eliot Miranda &lt;<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; Right.  And because Smalltak can&#39;t reify variables and CAS is an operation<br>
&gt; on a variable CAS can&#39;t be implemented as a primitive on variables.  There&#39;s<br>
&gt; no way to express &quot;pass a variable to a primitive&quot;, only &quot;pass an expression<br>
&gt; (which may be the value of a variable)&quot; to a primitive&quot;.  One could do it<br>
&gt; with a primitive on an object, e.g. thisContext at: tempIndex compareWith:<br>
&gt; match andSetTo: expr, or anObject instVarAt: varIndex compareWith: match<br>
&gt; andSetTo: expr but that&#39;s soooo ugly.  Hence I think it is better done using<br>
&gt; a special assignment operator.<br>
<br>
</div>Eliot, if this not a bytecode (which is much more lightweigth to primitive),<br>
then why bother ?<br></blockquote><div><br></div><div>I&#39;m sorry; I thought it was obvious that the above would be implemented as a bytecode since := is a (set of) bytecode(s).  In fact it would be three bytecodes, e.g. cassignTemp, cassingnInstVar and cassingnLitVar.</div>
<div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
It is trivial to implement a primitive like:<br>
<br>
Array&gt;&gt;compareAt: index with: value andStore: anObject<br>
 &lt;primitive: &#39;primitiveCAS&#39; &gt;<br></blockquote><div><br></div><div>Yes, but that requires two primitives (inst vars and indexed vars) and doesn&#39;t work elegantly on temp vars so I think expressively it&#39;s very poor.  Whereas the bytecode is elegant and operates where I want it on variables.  Do you see much utility for cas on arrays instead of cas on inst, temp and global vars?</div>
<div><br></div><div>best</div><div>Eliot</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
...<br>
<br>
so, then you can do:<br>
<br>
moo := Array with: 100.<br>
<br>
oldValue := moo compareAt: 1 with: 100 andStore: 2.<br>
self assert: oldValue == 100.<br>
self assert: moo first == 2<br>
<font color="#888888"><br>
<br>
<br>
--<br>
</font><div><div></div><div class="h5">Best regards,<br>
Igor Stasenko AKA sig.<br>
<br>
</div></div></blockquote></div><br>