[Pharo-dev] Can someone explain me what this code doing?

Igor Stasenko siguctua at gmail.com
Mon Aug 26 16:47:27 EDT 2013

NewValueHolder>>contents: anObject

    | oldValue |
    lock ifTrue: [ ^ self ].
    lock := true.
    oldValue := contents.
    contents := anObject.
     [ self contentsChanged: oldValue ] ensure: [ lock := false ].
    ^ contents

it is really interesting.. it appears you cannot change the contents
of value holder (as you can see it will simply ignore it) when it
'locked' during announcing the change event.

i know, this will prevent it from entering recursive loop,
but i would instead throw an error in such case(s)
because code which modifying the value as a reaction on value change
is something really stupid and must be fixed, instead
of putting workaround which will block the value holder from
accepting new value(s).. and that is really bad:
 - notification(s) about some property change should not
block the value from being able to be changed

Best regards,
Igor Stasenko.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pharo.org/pipermail/pharo-dev_lists.pharo.org/attachments/20130826/08ea5fcf/attachment-0002.html>

More information about the Pharo-dev mailing list