<br><br><div class="gmail_quote">On Wed, Oct 13, 2010 at 9:22 AM, Igor Stasenko <span dir="ltr"><<a href="mailto:siguctua@gmail.com">siguctua@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 13 October 2010 18:54, Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>> wrote:<br>
><br>
> Right. And because Smalltak can't reify variables and CAS is an operation<br>
> on a variable CAS can't be implemented as a primitive on variables. There's<br>
> no way to express "pass a variable to a primitive", only "pass an expression<br>
> (which may be the value of a variable)" to a primitive". One could do it<br>
> with a primitive on an object, e.g. thisContext at: tempIndex compareWith:<br>
> match andSetTo: expr, or anObject instVarAt: varIndex compareWith: match<br>
> andSetTo: expr but that's soooo ugly. Hence I think it is better done using<br>
> 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'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>>compareAt: index with: value andStore: anObject<br>
<primitive: 'primitiveCAS' ><br></blockquote><div><br></div><div>Yes, but that requires two primitives (inst vars and indexed vars) and doesn't work elegantly on temp vars so I think expressively it'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>