[squeak-dev] Re: Object>>#is:? (was: Re: PackageDependencyTest)

Michael van der Gulik mikevdg at gmail.com
Thu Mar 4 23:21:54 UTC 2010

On Fri, Mar 5, 2010 at 9:33 AM, Juan Vuletich <juan at jvuletich.org> wrote:
> Andreas Raab wrote:
>> For discussion, this is what I'm suggesting:
>> Object>>is: aSymbol
>>    "A generic membership test. Should be used to avoid the proliferation
>> of isXXX
>>    methods where appropriate. Use it like here:
>>        FooBar>>is: aSymbol
>>            ^aSymbol == #Foo or:[aSymbol == #Bar or:[super is: aSymbol]]
>>    This implementation can also be used with class names to replace the
>> usage
>>    of aMorph isKindOf: SketchEditorMorph with, e.g.,  aMorph is:
>> #SketchEditorMorph
>>    to avoid unnecessary dependencies on classes"
>>    "Check to see if aSymbol is a class name in the receiver's environment"
>>    self class environment
>>            at: aSymbol
>>            ifPresent:[:aClass| ^self isKindOf: aClass].
>>    ^false
> I believe #isKindOf: is really bad. Reasons for this are given in
> http://userweb.cs.utexas.edu/~wcook/Drafts/2009/essay.pdf . This was also
> discussed here, you can google for the name of the pdf in the archives.
> In the Cuis implementation of Object>>#is: there is no call to #isKindOf:.
> The idea is to ask for a protocol, not for inheritance.

It sounds like Java-style Interfaces should be implemented.

(anObject implements: AnInterface) ifTrue: [ ... ]



More information about the Squeak-dev mailing list