visibility" of class object in favour of a global context

Andreas Raab andreas.raab at gmx.de
Wed May 28 05:32:44 UTC 2003


Hi Joel,

> Just read this line:
> "Are you sure this can't just be solved by improving the tools?
> If the Browser showed Object>>isFoo to be in the same 
> category as Foo and Bar, would it bother people as much that
> it was on Object?
> 
> Again, this doesn't make sense to me. I assume isFoo here is 
> referring to "is this Object an instance of the Foo class".

That's _not_ the question which is being answered by #isFoo in general.
These queries are typically intended to be polymorphic so their real meaning
is "do you understand what I think a Foo should be understanding"? Note that
in the previous I am saying "what I think" a Foo needs to understand. The
#isFoo messages are more like "weak type queries" where you may have many
different objects responding "yeah, I'm kinda like a foo here". Examples for
these queries are #isLiteral (are you a kind of thing that a compiler knows
how to get literal forms from?) #isCollection (can I send #do: #size and the
general collection protocol to you?) #isPlayerLike (are you and end-user
scriptable object?) etc. Sometimes (as in #isCollection) there is a certain
interface expected, oftentimes (like in #isLiteral) there isn't.

> But that's absurd to put that sort of method on Object,
> isn't it? Ie. in Java (yes, that's where I'm
> coming from) you would use instanceof, which should be easy 
> in Smalltalk:
> 
> (myObject class) == (Foo class)

If it maps straightforwardly to classes, then yes. Except that the above
test doesn't include subtypes so your query should be "myObject isKindOf:
Foo" which is generally considered bad style because it's early binding
something which is mostly meant as a role (interface) of some object.

Cheers,
  - Andreas



More information about the Squeak-dev mailing list