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

Andreas Raab andreas.raab at gmx.de
Thu Mar 4 22:28:04 UTC 2010


On 3/4/2010 12:33 PM, Juan Vuletich wrote:
> 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.

But inheritance implies protocol. There is nothing wrong with asking for 
protocol conformance based on inheritance; it is the same as 
implementing isNumber in class Number for the purpose of having 
subclasses inherit that.

The implementation that I've proposed is making that point. Thus (42 is: 
#Number) returns true, since 42 conforms to the Number protocol. If you 
had some other class that conforms to the number protocol without 
subclassing it, it is free to implement, e.g.,

ComplexNumericRepresentative>>is: aSymbol
	"I conform to the number protocol"
	^aSymbol == #Number or:[super is: aSymbol]

As a consequence, the #is: test is not an inheritance test at all.

Cheers,
   - Andreas



More information about the Squeak-dev mailing list