Smalltalk language limitation ?

Doug Way dway at mailcan.com
Sun Dec 5 04:56:24 UTC 2004


On Dec 4, 2004, at 11:21 PM, Aaron Gray wrote:

> If my understanding is right then you cannot send a message to an 
> object passed as a parameter to a method of another class.
>  
> Is this correct ?

No, you can do this.  (If I understand you correctly.)  In fact, there 
are probably thousands of methods in Squeak that do this. :-)

I just poked around for a minute in a browser, and the third method I 
ran across has an example of this.  See Rectangle>>areasOutside:.  The 
method is passed an object (parameter) with the name "aRectangle".  
Down in the method, the message #corner is sent to this parameter.

>  What about messages to instance variables ?

Not sure what you mean here.  If you can get to the instance variable, 
you can send a message to it.  (It is true that you can't reference an 
object's instance variable directly unless you are "inside" that 
object.  Smalltalk instance variables have the equivalent of 
"protected" access in C++/Java-speak.)

- Doug




More information about the Squeak-dev mailing list