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

Juan Vuletich juan at jvuletich.org
Thu Mar 4 20:33:57 UTC 2010


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.

Cheers,
Juan Vuletich



More information about the Squeak-dev mailing list