Protocol viewer ?

Gary McGovern garywork at lineone.net
Tue Sep 25 23:47:01 UTC 2001


That's Cool ! Great explanation.
Thanks!
Gary


----- Original Message -----
From: "Ned Konz" <ned at bike-nomad.com>
To: <squeak-dev at lists.squeakfoundation.org>
Sent: Tuesday, September 25, 2001 9:30 PM
Subject: Re: Protocol viewer ?


> On Tuesday 25 September 2001 12:44 pm, Gary McGovern wrote:
> > Hello Ned,
> > I'm really sorry to keep this thread going and I appreciate all the
effort
> > put into your replies, but I feel I have to clear something up here
(with
> > my exam only 3 weeks away).
> >
> > Protocol is defined in my course as:
> > A set of messages that an object understands
> > now when I evaluate
> > bill size
> > I get an error and so obviously bill doesn't understand the message
size.
>
> No, bill understands the message "size". But it's not something that is an
> appropriate question. You get an error because it understands it but can't
> answer it.
>
> If bill didn't understand size, you'd get a different error, one that says
> that it didn't understand it. Instead you get an error that says something
> like "is not indexable".
>
> > And therefore size isn't part of the protocol of bill. But it is listed
in
> > the entire protocol of  AdvancedB3DSceneMorph.
> > So I'm trying to find if size listed as part of the protocol of
> > AdvancedB3DSceneMorph.
> > is a flaw in the protocol browser or a flaw in the writing of the Class
> > AdvancedB3DSceneMorph. This will answer to me all I need to know.
>
> size is a rather special case. It's really only meaningful for objects of
> certain classes -- those with indexed slots (like Array, etc.). Not for
> Morphs, which are objects whose slots are all named. However, it's defined
in
> Object because you can make subclasses of Object that either do or do not
> have slots. It was put there more for code re-use than because all objects
> really understand size.
>
> So, although size is, in fact, part of the protocol of Morphs, calling it
> will result in an exception being thrown because Morphs aren't the right
kind
> of object to answer size.
>
> Chalk this one up to Smalltalk history (Dan Ingalls could say much more
about
> this, I'm sure), rather than good OO design.
>
> If this wasn't defined in Object, every time someone made a new class with
> indexed slots that inherited from a class without indexed slots (which
> doesn't happen very often) they'd have to define size in their new
> class.
>
> Remember, Smalltalk was written back when memory was very small and
> expensive; using inheritance to share code was important.
>
> You could define size in Morph to return the pixel size (like extent
does).
> But it would confuse Smalltalkers, who are used to thinking of size as a
> method that returns the size of a collection.
>
> --
> Ned Konz
> currently: Stanwood, WA
> email:     ned at bike-nomad.com
> homepage:  http://bike-nomad.com
>
>
>





More information about the Squeak-dev mailing list