[Newbies] Answering a question: Are messages objects? Running into a problem with sendTo:

Mark Miller mmille10 at comcast.net
Sat Dec 28 04:09:42 UTC 2019

I was trying to explain in a question on Smalltalk (on Quora.com) how
messages are also objects, and I'm running into a bit of a problem in trying
to demonstrate this in either Squeak or Pharo.

I started off using a simple example:

'5' asInteger --> 5

I can do the same thing with:

(Message selector: #asInteger) sendTo: '5' --> 5

This all works fine.

The response I got back from the person I was trying to convince was that
since I'm using syntax to create and send a message (using sendTo: with a
Message class), it's not really a message, because if a constructed message
with Message is a message, then why use syntax to send "sendTo:" to it? He
contends it's an object being used to represent a message. The actual
message gets sent in the process of evaluation (I suppose he thinks the
message is "unwrapped" from Message, and is sent under the covers).

I was going to try the following, to perhaps be more convincing (though I
don't know if this is a lost cause re. convincing), but I ran into a
problem. I tried translating the 2nd expression above into more explicit
terms, and I'm running into an exception I can't explain. To me, what I'm
doing is equivalent to the 2nd expression, but Smalltalk disagrees.

First version:

| m1 m2 |
m1 := Message selector: #asInteger.
m2 := Message selector: #sendTo argument: '5'.
m2 sendTo: m1.

I also tried the following:

(Message selector: #sendTo argument: '5') sendTo: (Message selector:

In both cases, in both Squeak and Pharo, it throws up an exception saying:

"Message(Object)>>doesNotUnderstand: #sendTo" (Squeak)


"Instance of Message did not understand #sendTo" (Pharo).

This is bizarre to me, because if I look at Message in a browser, I can
clearly see sendTo: is an instance method. Also, if it wasn't an instance
method, then my very first example wouldn't have worked. I suspect I'm
running into some underlying mechanics of how messages are sent, and how
object state works in expressions.

Is this a bug? Am I missing something in how I'm using sendTo:? Or, does my
experimentation reveal that I'm wrong about messages? :)

Thanks in advance for any clarity on this.

mmille10 at comcast.net

Sent from: http://forum.world.st/Squeak-Beginners-f107673.html

More information about the Beginners mailing list