<div class="gmail_quote">2010/4/1 Denis Kudriashov <span dir="ltr">&lt;<a href="mailto:dionisiydk@gmail.com">dionisiydk@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

I think usage of immutability for object modification tracking is not very well solution and not simple solution. With that you must put every code with your objects in block that catch ModificationException. You can&#39;t track arbitrarily object modifications in any other places of system.<br>


<br>I think more general approach is registering arbitrary modification handler on object mutation like<br><br>object handleMutationBy: [:mutation | ]<br>and <br>object resetMutationTracking<br><br>And maybe it can be implemented like immutability approach. with single bit in object header. VM check this bit for #at:put: like primitives and send message #handleMutation: to target object if It set.<br>


<br>And now immutability logic with ModificationException has very simple implementation in language side<br><br>Object&gt;&gt;handleMutation: aMutation<br>   self raise: (ModificationException new mutation: aMutation)<br>


<br>Implementation of my messages:<br><br>Object&gt;&gt;handleMutation: aMutation<br>  self trackMutation.<br>  ^mutationHandler value: aMutation<br><br>And VM needs two primitives: #trackMutation and #resetMutationTracking<br>


<br></blockquote><div><br>Sorry, I little mistake. What I try wrote is:<br><br>Object&gt;&gt;handleMutation: aMutation<br>  
^mutationHandler value: aMutation<br><br>Object&gt;&gt;handleMutationBy: aBlock<br>  self trackMutation.<br>  mutationHandler := aBlock<br><br>And immutable logic can be like that:<br><br>Object&gt;&gt;beImmutable<br>  self handleMutationBy: [:mutation | self raise:  (ModificationException new mutation: aMutation)]<br>

<br>Object&gt;&gt;beMuttable<br>  self resetMutationTracking<br><br><br> <br></div></div>