Trouble Getting adjusted to Smalltalk

Ned Konz ned at bike-nomad.com
Tue Oct 23 05:57:06 UTC 2001


On Monday 22 October 2001 10:25 pm, Justin Walsh wrote:
> Please Ned! Listen to the guy. He has a simple conceptual block like we
> have all  had. geekSpeak will certainly drive him away. Or may not?

Hmm... I'll try to put it in English...

> > You can "browse senders" of the method in question. 

That is, if you're looking at a method, you can use the menu item "senders 
of..." and choose the method name. You'll get another browser with all the 
methods that call the method you're looking at. You can look to see what 
those methods send the method you're looking at.

Let's say I'm looking at Morph>>bounds: trying to figure out what newBounds 
ought to be.

If I look at senders of bounds: I see a lot of methods. The first one 
(AlansTextPlusMorph>>makeBookStyle:) calls bounds in a phrase like:

	r _ 4@(prev bottom + 4) corner: (self right - 4 @ (prev bottom + pageGap - 
4)).
	rm _ RectangleMorph new bounds: r

So now I know that the argument to bounds: (r) is something that is made by 
sending a Point (4@(prev bottom + 4)) the message #corner:. So if I look at 
Point>>corner: (which I can do with "browse implementers of...") I see that 
it says "Answer a Rectangle...".

So I know that Morph>>bounds: takes a Rectangle.

>> You can "browse implementors" of the methods that are called on the 
parameter you're trying to figure out.

On the same method, I see that the parameter (newBounds) is sent the messages 
"extent" and "topLeft". Looking at implementors of both extent and topLeft, I 
see several classes (Rectangle and Morph among them).

So I would guess that anything that would answer a Point when sent extent or 
topLeft would be an appropriate argument for this method. This includes 
Rectangles and Morphs.

Of course, "type" in Smalltalk is a considerably looser concept than in Java; 
in Java it relates directly to inheritance or implementation of an interface. 
In Smalltalk, since there are no explicit interfaces, if an object responds 
correctly to the messages you're sending it, it's the right type.

> > Things like aBounds are idiomatic; generally speaking, bounds will be a
> > Rectangle, and extent will be a Point.
> >
> > > I guess if more methods were documented it would be easier.  All I know
> > > is right now I'm having great difficulty using the available classes
> > > without finding external documentation on a web page somewhere.
> >
> > The Method Finder and Message Names tools are very helpful, I find.

Seriously. Look at them.

-- 
Ned Konz
currently: Stanwood, WA
email:     ned at bike-nomad.com
homepage:  http://bike-nomad.com




More information about the Squeak-dev mailing list