[squeak-dev] Re: immutibility

Denis Kudriashov dionisiydk at gmail.com
Thu Apr 1 05:37:32 UTC 2010


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't track
arbitrarily object modifications in any other places of system.

I think more general approach is registering arbitrary modification handler
on object mutation like

object handleMutationBy: [:mutation | ]
and
object resetMutationTracking

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.

And now immutability logic with ModificationException has very simple
implementation in language side

Object>>handleMutation: aMutation
   self raise: (ModificationException new mutation: aMutation)

Implementation of my messages:

Object>>handleMutation: aMutation
  self trackMutation.
  ^mutationHandler value: aMutation

And VM needs two primitives: #trackMutation and #resetMutationTracking
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20100401/83816f22/attachment.htm


More information about the Squeak-dev mailing list