pharo-graphics / Bloc

Low-level UI infrastructure & framework for Pharo
MIT License
80 stars 39 forks source link

Using slot for Immutable check #428

Open Ducasse opened 7 months ago

Ducasse commented 7 months ago

I wonder if we could not use slots to handle such cases

opacity: aNumber

    self
        assert: [ aNumber between: 0.0 and: 1.0 ]
        description: [ 'Opacity value must be within interval [0..1]' ].

    opacity isNotNil
        ifTrue: [ (BlImmutableObjectChangeError object: self) signal ].

    self opacity = aNumber
        ifTrue: [ ^ self ].

    opacity := aNumber
tinchodias commented 7 months ago

I'd be better, I agree. We are converting the asserts of the style of aNumber between: 0.0 and: 1.0 to method comments.

Ducasse commented 7 months ago

The assert for range are useless. in Morphic I do not recall problem with such design in alpha or others.

Ducasse commented 7 months ago

Now the immutability is something else to me.