AW: [squeak-dev] The Inbox: Traits-pre.307.mcz

Rein, Patrick Patrick.Rein at hpi.de
Fri Nov 20 14:07:22 UTC 2015


I want to add some more reasoning to this commit. The commit is intended to fix this issue: http://bugs.squeak.org/view.php?id=7767

My implementation is based on the corresponding Pharo Traits implementation, except for the TraitsComposition>>#printOn: implementation. Do you think it is worth also recreating that behavior?

In general, the most important thing regarding this change is, that this might break older .st or .cs files containing Traits definitions based on the old evaluation order.

Bests
Patrick
________________________________________
Von: squeak-dev-bounces at lists.squeakfoundation.org <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von commits at source.squeak.org <commits at source.squeak.org>
Gesendet: Freitag, 20. November 2015 09:52
An: squeak-dev at lists.squeakfoundation.org
Betreff: [squeak-dev] The Inbox: Traits-pre.307.mcz

A new version of Traits was added to project The Inbox:
http://source.squeak.org/inbox/Traits-pre.307.mcz

==================== Summary ====================

Name: Traits-pre.307
Author: pre
Time: 20 November 2015, 2:58:26.562 pm
UUID: f0955b2d-775c-4862-85b9-5d6e616cd2e4
Ancestors: Traits-eem.306

This fixes http://bugs.squeak.org/view.php?id=7767 which is about the - and @ operator of Trait compositions ignoring brackets. This implementation uses the normal left to right evaluation order of Smalltalk to avoid confusions about the way trait composition expressions are evaluated.

=============== Diff against Traits-eem.306 ===============

Item was changed:
  ----- Method: TraitAlias>>printOn: (in category 'operations') -----
  printOn: s
        "Answer the trait composition string (used for class definitions)"
+       s nextPutAll: '('.
        s nextPutAll: subject asString.
        s nextPutAll: ' @ {'.
        aliases do:[:assoc| s print: assoc] separatedBy:[s nextPutAll:'. '].
        s nextPutAll: '}'.
+       s nextPutAll: ')'.!
- !

Item was changed:
  ----- Method: TraitComposition>>- (in category 'converting') -----
  - anArray
-       "the modifier operators #@ and #- bind stronger than +.
-       Thus, #@ or #- sent to a sum will only affect the most right summand"

+       self updateTraits: (self traitsCollect: [:aTrait | aTrait - anArray ])!
-       self addLast: (self removeLast - anArray)!

Item was changed:
  ----- Method: TraitComposition>>@ (in category 'converting') -----
  @ anArrayOfAssociations
+
+       self updateTraits: (self traitsCollect: [:aTrait | aTrait @ anArrayOfAssociations ])!
-       "the modifier operators #@ and #- bind stronger than +.
-       Thus, #@ or #- sent to a sum will only affect the most right summand"
-
-       self addLast: (self removeLast @ anArrayOfAssociations)!

Item was added:
+ ----- Method: TraitComposition>>traitsCollect: (in category 'accessing') -----
+ traitsCollect: aBlock
+       ^self collect: [:each| each traitsDo: aBlock]!

Item was changed:
  ----- Method: TraitComposition>>traitsDo: (in category 'accessing') -----
  traitsDo: aBlock
+       ^self do: [:each| each traitsDo: aBlock]!
-       ^self do:[:each| each traitsDo: aBlock]!

Item was added:
+ ----- Method: TraitComposition>>updateTraits: (in category 'converting') -----
+ updateTraits: aCollection
+
+       self
+               removeAll;
+               addAll: aCollection!

Item was changed:
  ----- Method: TraitExclusion>>printOn: (in category 'composition') -----
  printOn: aStream
        "Answer the trait composition string (used for class definitions)"
+       aStream nextPutAll: '('.
        aStream nextPutAll: subject asString.
        aStream nextPutAll: ' - {'.
        exclusions asArray sort do:[:exc| aStream store: exc] separatedBy:[aStream nextPutAll: '. '].
+       aStream nextPutAll: '}'.
+       aStream nextPutAll: ')'.!
-       aStream nextPutAll: '}'.!



More information about the Squeak-dev mailing list