Object: Identity vs. Environment

Joel Shellman joel at ikestrel.com
Fri Jun 6 23:13:58 UTC 2003


> You have forgotten inheritance.  Instead of simply writing
>
>     fulfills: aSymbol
>         ^aSymbol == #Colorness
>
> in Color, one would have to write
>
>     fulfills: aSymbol
>         ^aSymbol == #Colorness or: [super fulfills: aSymbol].
>
> That is, every method which asserts that instances of a class have
> some property would be MORE complicated than the corresponding
> #isFoo method would have been.

No, you wouldn't do it that way--as you say, that would indeed be bad. The
entire implementation could be in Object. Object would create a
dictionaryOfFulfilling and then:

Object>>fulfills: aSymbol
    ^dictionaryOfFulfilling containsKey: aSymbol

(I guess this would be a class method or something, but I'm still new with
smalltalk.)

And then in any object/class, whenever it became such that it would fulfill
for a given aSymbol (likely during initialization, but if during runtime it
could morph into it, then runtime could add or remove it at will) it would
add that symbol to it's dictionaryOfFulfilling. That's one way, there are
others, but this is simple enough. It's a simplistic dynamic way of
declaring arbitrary marker interfaces.

-joel



More information about the Squeak-dev mailing list