Hi Paul,

You can set the object to be "read only" (aka "immutable") and handle the
exception.

E.g.

| u |
u := User named: 'Paul'.
u beReadOnlyObject.
[ "your code modifying u's state" ]
on: ModificationForbidden
do: [ :ex |
ex halt.
 "inspect state"
u beWritableObject.
ex resume
].

Probably there is a better way to do this with slots, using default ones or
subclassing `InstanceVariableSlot` for that instance only and halting on
the `write:to:` method of it.

Regards,

Esteban A. Maringolo


El mié., 2 ene. 2019 a las 15:45, PAUL DEBRUICKER via Pharo-users (<
pharo-users@lists.pharo.org>) escribió:

> Hi -
>
> Is there a way to haltOnChange or some such for an object?
>
>
> I have an instance that gets into a state I don't understand and would
> like to watch it or several of its inst vars for when they change.
>
> I could set a lot of #haltIf: statements and step through but hope someone
> has a better strategy
>
>
> thanks & happy new year.
>
>
> Paul
>

Reply via email to