Shrinking

Pavel Krivanek squeak1 at continentalbrno.cz
Mon Aug 30 07:18:14 UTC 2004


> So, this is a Smalltalk's feature ?
>
> It's rather strange and amazing to me.

Yes, it's basic feature. Look at this code:

| var |
var := 'string' factorial.
[ var Smalltalk ] System.

This code is valid even though factorial isn't method in class String,
Smalltalk isn't message selector but global variable, System isn't message
selector nor global variable - it's only an existing symbol.

But this lax control has very good reasons.

> Do you have a pointer explaining this behavior and how
> does it work ?
>
> Does it have anything to do with late binding ?
>
> When will the missing selector and its implementation
> be discovered ?

It's simple. When you compile a method, you create a CompiledMethod
instance. It contains an array of literals - in this case it's symbol
#factorial, string 'string', symbol System and symbol Smalltalk.

In bytecode you only tell - you've got an object on the top of the stack.
Send a message identified by literal #3 to it. If the called object doesn't
know this method, it generates an exception MessageNotUnderstood.

Smalltalk is an incremental system. When you write a method, you don't know
all classes and messages present in system in time of execution. It gives
you amazing freedom but you've got to test your programs accurately.

Pavel




More information about the Squeak-dev mailing list