[Pharo-dev] Deprecating ValueHolder (call for Spec user)

Stephane Ducasse stepharo.self at gmail.com
Wed Oct 4 15:55:48 EDT 2017


Hi

we have ValueHolder and NewValueHolder
so I wanted to remove the 6 last user of ValueHolder.

Now I see that we have

ValueHolder >> contents: newContents
      contents := newContents.
      self changed: #contents

NewValueHolder >> value: anObject
    self handleCircularReferencesWhile: [ | oldValue |
    oldValue := value.
    value := anObject.
    self valueChanged: oldValue ].

    ^ value

So

dialog newSliderFor: (ValueHolder new contents: 0.5)
getValue: #contents setValue: #contents: help: 'This is a slider').

=>
(dialog newSliderFor: (NewValueHolder new value: 0.5; yourself)
getValue: #value setValue: #value: help: 'This is a slider').

and I find that boring to have to be forced to use yourself.

as an experiment I changed the definition of value: to

NewValueHolder >> value: anObject
    self handleCircularReferencesWhile: [ | oldValue |
    oldValue := value.
    value := anObject.
    self valueChanged: oldValue ].

Now I'm looking for spec users to tell me if I break something.

Stef




More information about the Pharo-dev mailing list