Skip to content
Sean DeNigris edited this page Sep 9, 2019 · 2 revisions

Comparison via Descriptions

The message #isSameAs: determines whether the fields described by an object's Magritte descriptions are all equal for two objects. To have #= work the same way, simply delegate like so:

= rhs
	^ self isSameAs: rhs

Note that, whenever you redefine #= it is important to redefine #hash appropriately. Luckily, there is #maHash which bitXor-s the field values. Another quick delegation and you're in business:

hash
	^ self maHash

Meta-Described Accessors

Given aDescription, like MABooleanDescription new, you can now work with accessors via Magritte (e.g. in a Morphic form).

As a test, let's try to use our description to read Smalltalk os isMacOSX:

In a MA Morphic form, click "Remove" for the current null accessor. Now choose MAChainAccessor from the dropdown In the popup form: a. For the first accessor, choose MASelectorAccessor the dropdown and fill os into the edit field b. For the second accessor, choose MASelectorAccessor the dropdown and fill isMacOSX into the edit field Now, DoIt: myDescription read: Smalltalk "==> true | false"

Clone this wiki locally