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

Michael Haupt mhaupt at gmail.com
Thu Mar 4 19:33:14 UTC 2010


Hi,

Am 04.03.2010 um 19:58 schrieb Andreas Raab <andreas.raab at gmx.de>:
> 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 like it.

We've frequently had hard times explaining to students why monkey  
patching is (used to be?) somewhat idiomatic in Squeak. Good to have  
this, it does away with one particular awkwardness and thus makes  
Squeak a little bit easier to grasp.

Best,

Michael



More information about the Squeak-dev mailing list